Quantcast
Channel: Pochampalli IT Labs
Viewing all articles
Browse latest Browse all 261

Batch script to run MS SQL server sql commands

$
0
0

 Hi, use "sqlcmd" utility in batch script run a set of sql commands/queries through batch script. 

Make sure to install the following odbc driver and command line utility
msodbcsql.msi and MsSqlCmdLnUtils.msi

runsql.bat
@echooff
sqlcmd -U "sa" -P "MyPassword#123" -S 11.123.4.56 -i "C:\SQLScripts\CleanUp.sql"
timeout /t 5 /nobreak
exit


CleanUp.sql
use abcDatabase
deletefrom accountTable where AccountId='123'


I hope you find this useful! If you like it, pls do subscribe my YouTube channel for automation or tech updates.

Viewing all articles
Browse latest Browse all 261

Trending Articles



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