run sql script against database from management studio
Posted on 2013-12-03
I have a number of sql databases in an instance and need to run a sql script on the operating system against each database;
I have the query below which runs against each database but when i add a sql command like sqlcmd -i c:\upgrade.sql against each database it won't work;
EXEC master..sp_MSforeachdb '
IF ''?'' <> ''master'' AND ''?'' <> ''model'' AND ''?'' <> ''msdb'' AND ''?'' <> ''tempdb''
print ''Processing database ?''
sqlcmd -i c:\upgrade.sql
how can i run my upgrade scrip agains the 50 database in my instance from sql management studio or some other better way ?