SQL script on multiple databases

  • Hi.

    I want to run one simple script on many DB in the same server.

    How can I do it?

  • There are a couple of ways to do it. Will you be doing this often, or just once?

    If often, RedGate (link at the top of the page) has a product for that kind of thing.

    If once, take a look at sp_MSForEachDB. It's not documented, but there's good data about it if you Bing/Google it.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Thanks

    Your advice was very useful.

  • You're welcome.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • @barakos,

    To add to the list, since you are using SQL Server 2008 you can make use of SSMS to run query against multiple servers by registering the instances. More details here[/url]

    Pradeep Adiga
    Blog: sqldbadiaries.com
    Twitter: @pradeepadiga

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply