Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Exec scripts in a group of databases

By William Talada,

If you generally execute your scripts against a group of databases, create a template like the one above and drag it to the top of your script in the script window. Hit execute three times to cycle through them to apply your script to all databases in the group.

Make the group circular if you want to be able to start with any database in the group.
Make it linear if you always want to execute changes to older or newer versions in a progressive manner.

The first three lines above make it jump into the group from any database. You can remove those lines for more secure control.

If you implement a circular list, start with the last database in your group so it will be changed to the first before executing your script, if order is important to you.

Sometimes it is little tricks like this that make the workday so much better. F.Y.I. a "USE" statement may not be put in a stored procedure, trigger, or function.

Total article views: 1001 | Views in the last 30 days: 1
 
Related Articles
FORUM

URGENT: Error executing scripts......

URGENT: Error executing scripts......

FORUM

Connditional executing of script

Connditional executing of script

FORUM

multiple database creation script

how to execute schema creation script and maintain them in a database ?

BLOG

A Script A Day - Day 11 - User Permissions By Database

Today's script will return you permissions granted to a user for every online database.  The script ...

Tags
administration    
automation    
templates    
 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones