4 SQL scripts, need them run thru multiple DBs on a SQL server weekly

Obsoleet

Platinum Member
Oct 2, 2007
2,181
1
0
What's the best way to do this?

These are the requirements, there are 4 scripts that do database maintenance, I need a script that will run all 4 scripts on each database on the server, then after that is done on 1 DB, it moves along to the next database.. running the 4 scripts on each DB sequentially.

I've looked into built-in SQL maintenance schedules and I think what would be better is some sort of scheduled job I place on the SQL server, and it runs each script sequentially on each DB sequentially that's located on the server.

I need it to be portable, so if we setup a new SQL instance on a server, I can just place the batch file and SQL scripts on the server as a scheduled task, and it will do the work without further customization.

Any ideas or suggestions? Thank you in advance
 

KLin

Lifer
Feb 29, 2000
30,950
1,076
126
nvm, didn't read the requirements thoroughly.
 
Last edited:

LokutusofBorg

Golden Member
Mar 20, 2001
1,065
0
76
You can use SSIS to execute scripts from disk so that you don't have to go around updating the actual tasks inside SQL Server if you ever update the scripts. Just drop updated versions into the folder on each of your servers.
 

Obsoleet

Platinum Member
Oct 2, 2007
2,181
1
0
nvm, didn't read the requirements thoroughly.

I'd still like to hear it, because I'm trying to learn new ways to do things, what was your suggestion? Requirements could change slightly in some respects if they are silly/unnecessary and I don't see that. Just looking for the best way in an environment with my SQL servers to have a generic 4 script set run on each DB sequentially.

Don't care how its done as long as I can easily port the setup to a new server quickly.
 

wanderer27

Platinum Member
Aug 6, 2005
2,173
15
81
Yeah, I agree with LokutusofBorg, you can set up multiple task in a Sequence container with SSIS without too much trouble.

To implement on a new Server all you'd need to do is just change the Connection Manager.
 

brandonbull

Diamond Member
May 3, 2005
6,365
1,223
126
What about creating linked servers on the fly and then executing dynamic sql code against the different servers using values from a parameters table?