July 27, 2009 at 2:12 am
Hi
I am trying to automate a SQL Script to run against a number of instances.
I am using the following batch file:
FOR /F "tokens=1" %%a in ("SERVERLIST.txt")DO SQLCMD -S %%a -E -i test.sql -o results.txt
When I run the script I get the following in a command prompt:
C:\DAILYCHECKS>FOR /F "tokens=1" %a in ("SERVERLIST.TxT") DO SQLCMD -S %a -E -i
test.sql -o results.txt
C:\DAILYCHECKS>SQLCMD -S SERVERLIST.TxT -E -i test.sql -o results.txt
When I look at the results file I get the following:
HResult 0x35, Level 16, State 1
Named Pipes Provider: Could not open a connection to SQL Server [53].
Sqlcmd: Error: Microsoft SQL Native Client : An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections..
Sqlcmd: Error: Microsoft SQL Native Client : Login timeout expired.
The serverlist.txt only has one instance in it at the moment.
I can connect to it by SQLCMD from the command line if I enter:
SQLCMD -S Server\Instance
I assume that the am a entering the incorrect SQLCMD paramaters.
Does anyone know what I am doing wrong.
Thanks in advance
Chris
July 27, 2009 at 6:54 am
This worked for me
FOR /F "tokens=1" %%a in (SERVERLIST.txt) DO SQLCMD -S %%a -E -i test.sql -o results.txt
the file name shouldn't be quoted.
Let me know if that works
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply