Link to home
Start Free TrialLog in
Avatar of Aleks
AleksFlag for United States of America

asked on

Can I run one script in multiple sql databases at once ?

I have a server with over 50 databases, they are all exactly the same, for liability reasons we need to keep them separate. Every week or so I need to run a script to update them, it is the same script for all 50 databases.
Is there a way to run the script ONCE and have it update ALL selected databases ?  It is a pain to have to run it 50 times.
I am using MS SQL 2008 RC2.
ASKER CERTIFIED SOLUTION
Avatar of itmarsolutions
itmarsolutions
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Aleks

ASKER

What if I want to select which databases to run it on ?
There are a few databases there that are not related to this one particular service and those need to remain untouched.
you can avoid that database in this line

WHERE name NOT IN ('master','model','msdb','tempdb')
Avatar of Aleks

ASKER

Thanks .. I actually found the perfect tool. RedGate has 'multi script', allows to run scripts in multiple databases and actually multiple sql servers as well. Will make managing the lists of databases easier !

Thanks though !

A