I'm trying to execute a SQL Server stored procedure from a batch file. At the moment, it works fine on my pc (using localhost) but I need to use it in another PC, my stored procedure uses queries with linked server and when I trying to execute my batch file I get these messages:
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Named Pipes Provider: Could not open a connection to SQL Server [53]. .
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Login timeout expired.
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : 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..
Maybe I need to send also my user and password in my batch file? Currently this is what I have in my .bat:
sqlcmd -Q "exec SP #Param= 1" -SServerIP -dDATABASE -o PATHTOMYTXTINFOFILE
Related
Currently we are manually running the scripts in SQL Server. We are trying to automate this execution by using Nexus repository. We are able to successfully create workflows using Nolio agent but while executing the workflows sqlcmd is throwing error as below :
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. 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..
We are able to successfully run this process via putty but getting error only when we run using nexus repository by triggering Nolio agent. Any idea what am I doing wrong here?
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
We're using Tidal 6.5.3.164. I'm running a SQL Server stored procedure using sqlcmd. It works when I specify the server but I want to use a Tidal variable for the server and it's not working. In the Command line I have sqlcmd. In the Command Parameters I have:
-E -S <Group.Report_Server> -Q "exec dbo.test_sproc"
I get the following error messages:
Sqlcmd: Error: Microsoft ODBC Driver 11 for SQL Server : Named Pipes Provider: Could not open a connection to SQL Server [53]. .
Sqlcmd: Error: Microsoft ODBC Driver 11 for SQL Server : Login timeout expired.
Sqlcmd: Error: Microsoft ODBC Driver 11 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..
My guess is sqlcmd is trying to connect to a server named <Group.Report_Server> because it works fine when I specify the actual server name. Any idea's how to use the variable with sqlcmd?
The problem was the Tidal variable was defined several levels higher and not in scope when I ran this. Normally this would run fine but the way I was trying to run it didn't work. Everything works as expected, I just had to learn more about Tidal.
I'm actually writing a little script that call sqlcmd.
There it is :
sqlcmd -S localhost\SQLEXPRESS -E -i Select_All.sql -o All_Tables_Name.txt
When i write this as a cmd line it works well.
When i put it in a .sh file sqlcmd can't connect to the Database and i get these errors :
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Named Pipes Provider: Could not open a connection to SQL Server [53]. .
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Login timeout expired.
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : 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 tried to change the -S argument with the Machine name or by '.' but still doesn't work.
Can someone explain me why is it different when i write it as a command line and when i launch it from a script Please ? (like "sh MyScript.sh")
Thank you.
I am having trouble connection to a local instance of Microsoft SQL Server 2012, this is what i have tried so far:
SQL Server Configuration Manager
Enable TCP/IP
Enable Named Pipes
Enable Shared Memory
The SQL Server, SQL Server Browser and SQL Server Agent services are all running.
I have verified that there is a SQL Server instance with: sqlcmd.exe -L this command gives me the following:
Servers:
(local)
MON-W530
SQLCMD
sqlcmd.exe -S MON-W530\MSSQLSERVER -E Gives the following output:
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : SQL Server Network Interfaces: Connection string is not valid [87]. .
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Login timeout expired.
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : 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..
OSQL
OSQL.EXE -S MON-W530\MSSQLSERVER -E Gives the following output (Identical to sqlcmd.exe above)
[SQL Server Native Client 11.0]SQL Server Network Interfaces: Connection string is not valid [87].
[SQL Server Native Client 11.0]Login timeout expired
[SQL Server Native Client 11.0]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.
Its a fresh installation of Microsoft SQL Server 2012 Developer Edition, any help is appriciated.
Edit
Using SQL Server Management Studio 2012, i don't have the option to specify username and password for Windows Authentication, so i guess its not enabled, any clues on enabling Windows Auth is also appriciated.