Monday, January 3, 2011

SQLCMD command line utility

To run multiple external scripts do as follows;

Suppose you are having following scripts in a folder. c:\scripts\script1.sql, c:\scripts\script1.sql

If you add the following example to .bat file ,it runs those scripts from the command line and outputs the queries and results to a text file located at C:\Result.txt.

sqlcmd -S ERANGA-PC\SQLEXPRESS -d T1 -U sa -P Qwer1234 -i c:\scripts\script1.sql -i c:\scripts\script1.sql –o c:\scripts\Result.sql

No comments: