patternsqlModerate
Scheduled stored procedure on all databases in my server
Viewed 0 times
storeddatabasesallprocedureserverscheduled
Problem
On SQL Server 2012 (not express edition) I'd like to schedule the execution of a stored procedure every hour.
On the same server I have lot of databases with the same structure, and I'm constantly adding new db.
How can I schedule the execution of the same stored procedure on all the databases (if this exists in the database)?
On the same server I have lot of databases with the same structure, and I'm constantly adding new db.
How can I schedule the execution of the same stored procedure on all the databases (if this exists in the database)?
Solution
Use the better version of the undocumented sp_MSForEachDB to iterate through the databases in a SQL Server Agent job.
Or simply use a WHILE loop yourself on sys.database entries if you have a naming pattern.
Or simply use a WHILE loop yourself on sys.database entries if you have a naming pattern.
Context
StackExchange Database Administrators Q#42061, answer score: 10
Revisions (0)
No revisions yet.