sqlcmd - problem to connect with sql credentials - sql-server

I have a SQL database service in Azure with a server name dummyserver.database.windows.net.
I have also a database dummyDB with user dummyuser.
I can connect there providing above parameters and credentials with Azure Data Studio and other DB tools.
But when I try to do the same tith sqlcmd i get an error:
sqlcmd -S dummyserver.database.windows.net
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : MAX_PROVS: The system cannot contact a domain controller to service the authentication request. Please try again later.
.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Cannot generate SSPI context.
I went through https://learn.microsoft.com/en-us/sql/tools/sqlcmd-utility?view=sql-server-ver16
but haven't found any way to connect using login/password
In my case it is not even login issue because I don't get to this point yet.
My error is earlier.
Any hint what is wrong?

Related

Sqlcmd error while connecting with SQL Server instance on a VM using SQL Server proxy

I have created a private SQL Server instance and trying to access it on Virtual Machine instance using SQL Server proxy using the link (https://cloud.google.com/sql/docs/sqlserver/connect-instance-private-ip) on GCP platform
It worked well but today it was throwing the below 2 errors repeatedly while running the sqlcmd command
sqlcmd -S 127.0.0.1 -U sqlserver
Error:
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login timeout expired.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : TCP Provider: Timeout error [258].
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Unable to complete login process due to delay in prelogin response.
and
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. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections.
I am not sure how to resolve these issues.
When connecting to Cloud SQL via Cloud SQL Auth proxy, it is a requirement to start the proxy every time you attempt to connect to Cloud SQL as mentioned by #AlwaysLearning. I was able to reproduced your error and starting the Cloud SQL Auth proxy solved the problem.
Connecting to Cloud SQL without starting Cloud SQL Auth proxy:
As stated in the documentation you referenced, you start the Cloud SQL Auth proxy using this command:
./cloud_sql_proxy -instances=INSTANCE_CONNECTION_NAME=tcp:1433
Additionally if your Compute Engine instance is in the same region as your Cloud SQL instance, you may want to consider another way to connect these instances. In the Connect from Compute Engine documentation, you can find the instructions on how to connect from a CE instance to a private IP of a Cloud SQL instance as long as both of these instances are on the same region.
The above issue might occur when the private service access connection breaks for the SQL server instance on GCP platform. That is when some one mistakenly removes the peering.
The above error resolves when we create/update the existing peering connection. The solution is posted in the link Unable to recreate Private Service Access on GCP

ERROR Adaptive Server Requires encryption of the login password on the network - SQL Server Migration Assistant for Sybase

I'm trying to migrate Sybase Database to an SQL Server by assistant tool from Microsoft. When I try to connect to Sybase with ODBC Driver Provider in SQL Server Migration the error bellow appears.
ERROR [ZZZZZ][SAP][ASE ODBC Driver][Adaptive Server Enterprise]Adaptive Server requires encryption of the login password on the network.
ERROR [ZZZZZ][SAP][ASE ODBC Driver][Adaptive Server Enterprise]Login failed.
Analyzing my connection configured in ODBC Data Source Administrator I noticed that the Encrpyt Password flag is set and the Test Connection works fine (Login Succeeded).
I've been searching for a encrypt password connection string but I got other error
[IM002][Microsoft][ODBC Driver Manager]Data source name not found and no default driver specified.
Can anyone help me to solve this error?
ERROR [ZZZZZ][SAP][ASE ODBC Driver][Adaptive Server Enterprise]Adaptive Server requires encryption of the login password on the network
![ERROR [ZZZZZ][SAP]ASE ODBC Driver][Adaptive Server Enterprise]Adaptive Server requires encryption of the login password on the network

Error when trying to schedule auto backup in SQL Server Express

I am trying to create scheduled task for auto backup in SQL Server 2019 based on this article :
https://learn.microsoft.com/en-us/troubleshoot/sql/admin/schedule-automate-backup-database
As recommended in order to test if the auto backup is working, I have to run the batch file containing this command:
sqlcmd -S .\EXPRESS -E -Q "EXEC sp_BackupDatabases #backupLocation='c:\AutoBackup\', #backupType='F'"
I ran it in the command line to test if its working fine but I get the following error:
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : MAX_PROVS: Error Locating Server/Instance Specified [xFFFFFFFF]. .
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login timeout expired.
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. 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..
I installed Sql server ODBC driver for another issue that I faced before and also checked that remote connection is allowed as SSMS is working fine.
Any advice is appreciated.
Have you double checked that your SQL Express instance is actually named "EXPRESS"?
When you connected using SSMS, did you also used Windows Authentication?
Your command breaks down as follows:
This part defines the server/instance. IN this case on the local machine with a Named Instance of "EXPRESS"
sqlcmd -S .\EXPRESS
This part states that you want to use Windows Auth with the currently logged in user
-E

Login failed when I trying to connect to a SQL Server using sqlcmd (from Ubuntu command line)?

I am finding some problem trying to connect to a SQL Server instance from an Ubuntu machine using sqlcmd. The SQL server instance run on another server that is an always on MS-SQL Server cluster.
So I installed sqlcmd as explained here: https://learn.microsoft.com/it-it/sql/linux/sql-server-linux-setup-tools?view=sql-server-ver15#ubuntu
The SQL server seems to be reachable because I can successfully connect to the 1433 port of its IP via Telnet.
Then I tried to connect to one of my database on this server, in this way:
./sqlcmd -S MY-IP-ADDRESS -d ESB_WSO2_USER_DB -U datacenter\\wso2DBAdmin
Where:
ESB_WSO2_USER_DB is the DB name
datacenter\wso2DBAdmin is the domain\username
It ask me the password, I insert the password (pretty sure that the credential should be ok) but I am obtaining this error message:
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login failed
for user 'datacenter\wso2DBAdmin'..
Assuming that username and password are correct: what could be the problem? Is it something that could be related to my sqlcmd installation (maybe some missconfiguration), or the driver? or something related to my connection string? or something related to the SQL Server database?

SQL Server ODBC connection with Kerberos/AD Authentication

I have SQL Server that uses Kerberos authentication on my company's network. I am trying to setup a Linux system to be able to access that SQL Server using pyodbc. I am new to Kerberos, but have been able to get my Linux (Ubuntu 16.04) box working with Kerberos... Atleast thats what I think. I can do kinit <username> and it recognizes my username and password.
What do I do next?
If I do this:
sqlcmd -S MyDatabase.corp.com
I get this:
sqlcmd: Error: Microsoft ODBC Driver 11 for SQL Server : Cannot generate SSPI context.
Sqlcmd: Error: Microsoft ODBC Driver 11 for SQL Server : SSPI Provider: Cannot find KDC for realm "COMPANYNET.CORP.COM".
I am pretty sure I am just not doing the next step but I haven't found a good source to tell me what to do next. Any help is much appreciated... Thanks!
After much headache and annoying a lot of people at my company I got this to finally work.
Had to get a Service Account setup on the Domain
Had to get a krb5.keytab file made by an AD Admin
Had to setup Kerberos with the correct Domain in my /etc/krb5.conf file
Had to have SPNs set for the target SQL Server (This seems to be the actual cause of the above error message)
Ensure proper permissions set Service Account on SQL Server.
Once above was set I can do:
kinit -k <SERVICE ACCOUNT NAME>
sqlcmd -E -S MyDatabase.corp.com

Resources