Tag Archives: sqlcmd

How to run multiple SQL scripts

Scenario 1:- Create a .bat file with the below code and store the .bat file in the folder containing all the .sql scripts. setlocal SET SQLCMD=sqlcmd -S<servername\instancename> -d<database name> -E for %%d in (*.sql) do %SQLCMD% -i%%d endlocal Double click … Continue reading

Posted in SQL Server, T-SQL Scripts, Tricks | Tagged , | Leave a comment

Execute SQL script from command prompt

We are often required to run certain scripts or deploy scripts to sql server using command prompt; here how we can do it seemlessly. Open command prompt and type in the below sqlcmd mentioning the relevant servername /database name and … Continue reading

Posted in SQL Server, T-SQL Scripts, Tricks | Tagged , | Leave a comment