The simple way to run T-SQL script from batch file is using SQLCMD command. It's can be useful to run repeatable tasks like backups or restores.
Basic syntax is:
C:\Windows> sqlcmd -S SERVERNAME -o "OUTPUT_FILE.TXT" -U sa -P PASWORD -i C:\MySCRIPT.sql
Following article have more detailed information:
Using the SQLCMD command line utility for SQL SERVER
Basic syntax is:
C:\Windows> sqlcmd -S SERVERNAME -o "OUTPUT_FILE.TXT" -U sa -P PASWORD -i C:\MySCRIPT.sql
Following article have more detailed information:
Using the SQLCMD command line utility for SQL SERVER
Comments