May 22, 2013 at 8:18 am
Im running the following in a batch file
sqlcmd -Q "exec dbo.MySproc" -S "MyServer" -d "MyDatabase"
and Im getting the following error:
Named Pipes Provider: Could not open a connection to SQL Server [121]
Any idea what Im doing wrong?
May 22, 2013 at 8:21 am
dndaughtery (5/22/2013)
Im running the following in a batch filesqlcmd -Q "exec dbo.MySproc" -S "MyServer" -d "MyDatabase"
and Im getting the following error:
Named Pipes Provider: Could not open a connection to SQL Server [121]
Any idea what Im doing wrong?
You are not specifying to SQLCMD that it should use a trusted connection (-E) or providing a username/password (-U username -P password).
May 22, 2013 at 8:36 am
Provide User info while connecting using -E or -U switch,
-E : Is Trusted connection
-U : UserName to connect and later it will ask for pass to connect
May 22, 2013 at 11:59 am
Lynn Pettis (5/22/2013)
dndaughtery (5/22/2013)
Im running the following in a batch filesqlcmd -Q "exec dbo.MySproc" -S "MyServer" -d "MyDatabase"
and Im getting the following error:
Named Pipes Provider: Could not open a connection to SQL Server [121]
Any idea what Im doing wrong?
You are not specifying to SQLCMD that it should use a trusted connection (-E) or providing a username/password (-U username -P password).
when I tried his syntax, -E did not need to be included, as its the default according to Microsoft http://msdn.microsoft.com/en-us/library/ms180944.aspx and it worked for me without -E on 2008. I'm suspecting that he might instead not have his server set up for remote connections or has other connectivity issues. By default, SQL server installs with shared memory (local) connectivity only if I'm not mistaken.
May 22, 2013 at 12:09 pm
patrickmcginnis59 10839 (5/22/2013)
Lynn Pettis (5/22/2013)
dndaughtery (5/22/2013)
Im running the following in a batch filesqlcmd -Q "exec dbo.MySproc" -S "MyServer" -d "MyDatabase"
and Im getting the following error:
Named Pipes Provider: Could not open a connection to SQL Server [121]
Any idea what Im doing wrong?
You are not specifying to SQLCMD that it should use a trusted connection (-E) or providing a username/password (-U username -P password).
when I tried his syntax, -E did not need to be included, as its the default according to Microsoft http://msdn.microsoft.com/en-us/library/ms180944.aspx and it worked for me without -E on 2008. I'm suspecting that he might instead not have his server set up for remote connections or has other connectivity issues. By default, SQL server installs with shared memory (local) connectivity only if I'm not mistaken.
I'll be honest, I try to never rely on defaults (although I am sure I have on occasions). I have always found it better to explicitly state the connection whether Trusted or using a Username/Password. If someone else needs to work with the code I leave behind they aren't left guessing.
May 23, 2013 at 7:02 pm
LOL editted!
May 23, 2013 at 7:15 pm
dndaughtery (5/22/2013)
Im running the following in a batch filesqlcmd -Q "exec dbo.MySproc" -S "MyServer" -d "MyDatabase"
and Im getting the following error:
Named Pipes Provider: Could not open a connection to SQL Server [121]
Any idea what Im doing wrong?
Did you try the command on the same computer that the SQL server is running on? If its SQL express, did you supply the instance name also, this typically looks like:
sqlcmd -Q "exec dbo.MySproc" -S "MyServer\SQLExpress" -d "MyDatabase"
The reason I mentioned this is that you have to run additional setup to allow remote connections, but this should work right after the install if you run sqlcmd on the same computer the database server is running on.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply