MSSQL 2005: execute many MSSQL script by command (variable should be used)
Posted on 2010-09-09
that's say i have three MSSQL Script, step1.sql, step2.sql, step3.sql.
when i want execute these .sql scripts, i drag them into Microsoft SQL Server Management Studio and the execute them. But now i would like to write a batch file and execute theses .sql scripts just by click the .batch file.
can anyone tell me how do i write such .batch file.
One more question, in these files i call the database name by using "USE [dbname] " . And i would like to use a variable as database name, because i want let these scripts run for database with different name. Everytime i just need to run the batch file and input a parameter as database name.
any suggestion are greatly appreciated. thanks.