Executing T-SQL to multiple databases with Maintenance Plan??

  • The fact that you say that the maintenance plan only does things for certain databases makes it difficult to make it dynamic. But if you have some common way of identifying the databases you might be able to use the sp_MSForeachdb stored procedure.

    For example to execute some code on all databases with a name starting with UDB

    Exec sp_MSForeachdb

    'USE [?]IF DB_ID(''?'') LIKE 'UDB%"

    DO Something here'

    [font="Verdana"]Markus Bohse[/font]

  • Or you could have a job that goes through a list of databases and does what you want.

    "Keep Trying"

Viewing 2 posts - 1 through 3 (of 3 total)

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