December 1, 2007 at 6:42 am
I have a server which has around 25 database of similar structure.I have to update all the 25 databases with the same T-Sql and this has to be done on daily basis.So I thought of scheduling a job to execute on dialy basis at around midnight. Can I schedule a single job to execute T-sql in all the database? If yes how?
December 1, 2007 at 9:19 am
you could use the sp_msforeachdb (undocumented !! :ermm: )
Check SSC for some examples ....
http://www.sqlservercentral.com/Forums/Topic307978-146-1.aspx#bm309930
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
December 1, 2007 at 11:43 am
I'd use a single database, create a table, and then populate it with the names of the databases from master.dbo.sysdatabases. I'd then run a loop through this table and execute your code.
The reason?
You never know when something will change or you'll need to get a database out of the loop. MS_foreachdb doesn't allow you to exclude databases, and you might need to.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply