I can't connect to ms sql instance - internal
I got the same error. It was because I used -H mssqlserver
instead of -S mysqlserver
This worked for me
sqlcmd -U sa -S mssqlserver -P secret
In the question the -P
option is used for port and password, but it is only supported for the password.
If e port different from 1433
should be used, then pass it with the host name
sqlcmd -U sa -S mssqlserver,1444 -P secret
sqlcmd
Install instructions can be found in
https://docs.microsoft.com/en-us/sql/tools/sqlcmd-utility?view=sql-server-ver15
In case anybody cares about Emacs Org-babel
#+HEADER: :results table :engine mssql :dbhost mssqlserver :database master :dbuser sa :dbpassword secret
#+begin_src sql
SELECT name, database_id, create_date
FROM sys.databases;
#+end_src
Found in
- https://www.reddit.com/r/emacs/comments/e9lrcp/how_to_use_sqlmode_or_org_babel_to_execute_mssql/fakr7nw?utm_source=share&utm_medium=web2x
- https://emacs.stackexchange.com/questions/39112/org-babel-using-properties-as-code-block-header-arguments-how-to-make-it-work
Related videos on Youtube
batmanforever
Updated on September 18, 2022Comments
-
batmanforever over 1 year
The Platform and Software versions I am using are as follows :
Red Hat Enterprise Linux Server release 7.4 (Maipo) Microsoft SQL Server 2017 (RTM-CU3-GDR) (KB4052987) - 14.0.3015.40 (X64) Dec 22 2017 16:13:22 Copyright (C) 2017 Microsoft Corporation Express Edition (64-bit) on Windows Server 2012 R2 Standard 6.3 <X64> (Build 9600:) (Hypervisor)
I have searched a lot for answers on Google but haven't found any solution yet. I can't connect to
RDS instance having MS SQL instance
via Linux.It shows following errors If I try to :
[ec2-user@ip-~]$ sqlcmd -H mssqldb.xxxxxxxxxxxxxx.com -P 1433 -U userXXXXX -P aXXXXXX -Q 'SELECT TOP 1 [n] FROM [dbbase2].[dbo].[table_people]' Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login timeout expired. Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : TCP Provider: Error code 0x2749. Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. The server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online. [ec2-user@ip- ~]$ Check if instance name is correct and if SQL Server is configured to allow remote connections.
Could anyone please tell the issue and resolution ?
Thanks.
-
batmanforever about 6 years@PimpJuiceIT I tried to run: sqlcmd -S EC2XXXXXXXX -d dbXXXX -P 1433 -U userXXXXX -P aXXXXX -Q 'SELECT SELECT TOP 1 [n] FROM [Nums]' or: sqlcmd -S EC2XXXXXXXX -d dbXXXX -P 1433 -U userXXXXX -P aXXXXX Is the same error. I have got only a connection by SQL Server Management Studio from Windows 7 but there is a still a problem when I would like to connect through Linux.
-
batmanforever about 6 years@PimpJuiceIT I suspect but I'm not sure that maybe it is a problem with SQL Server Configuration Manager where I should set up TCP/IP protocols but I don't have access to this tool.
-
batmanforever about 6 yearsWhat I checked in Linux { I first run commands: sudo yum check-update and sudo yum update mssql-toolsthen I run: sqlcmd -S EC2XXXX-SERVERNAME\INSTANCE,1433 [ec2-user@ip-1 ~]$ sqlcmd -S EC2XXXX-SERVERNAME\INSTANCE,1433 Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login timeout expired. Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : TCP Provider: Error code 0x2AF9.
-
batmanforever about 6 yearsIn Windows this works and port is open every time: {telnet instance.XX..rds.amazonaws.com 1433}When I am checking telnet in Linux I see after a few seconds:{Trying 1XX.XX.XXX.XXX...Connected to INSTANCE.X.rds.amazonaws.com.Escape character is '^]'.Connection closed by foreign host. }
-
batmanforever about 6 yearsWhat do you mean about the specific version of the SQL Server instance? What is the quickest way to remove 17 ver drivers and install ODBC drivers 16 or 15?
-
batmanforever about 6 yearsOk, right. My version of MS SQL is on the top of this topic. This is :Microsoft SQL Server 2017 (RTM-CU3-GDR) (KB4052987) - 14.0.3015.40 (X64) Dec 22 2017 16:13:22 Copyright (C) 2017 Microsoft Corporation Express Edition (64-bit) on Windows Server 2012 R2 Standard 6.3 <X64> (Build 9600:) (Hypervisor)
-
batmanforever about 6 yearsBtw, I will be trying to solve this issue. Thanks for that.
-
zoechi almost 4 yearsWere you able to make this work?
-