Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

OS cmd from within SQLCMD

$
0
0

I have a batch file that contains a list of SQLCMD commands, as in...

SQLCMD -S server1,1433 -E -i "C:\testscript.txt" -o "C:\testscript_server1.out"
:quit

SQLCMD -S server2,1433 -E -i "C:\testscript.txt" -o "C:\testscript_server2.out"
:quit

::::::::::::::::::::::::::::::::::::::::::

C:\testscript.txt contains a series of T-SQL commands, plus DOS command to create folders and copy a file, as in...

::::::::::::::::::::::::::::::::::::::::::

T-SQL command....

::::::::::::::::::::::::::::::::::::::::::

!!MKDIR "C:\testFolder1"
!!MKDIR "C:\testFolder2"
!!COPY \\<local machine>\C$\MSSQLProcedures.dll "C:\testFolder1\"

Assuming that I run the batch file from my local machine, with the intention to connect to server1 & server2 and in each, create the two folders and copy the MSSQLProcedures.dll file, when executed, the folders and file creation operations occur on my local machine as opposed to on the servers.

Any insight and help here would be much appreciated. Thanks.



Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>