Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

I have a trigger that I need to run on all application databases that are in the domain.database(Table.Coloum) of a SLSYSTEM Database, Dont want to do it manually

10 views
Skip to first unread message

Sammy Singh

unread,
Apr 16, 2013, 3:43:15 PM4/16/13
to
I have a trigger that I need to run on all application databases that are in the domain.database(Table.Coloum) of a SLSYSTEM Database
So if I do a select databasename from domain on the system database I get the 250+ Application database name. So I want to run a Trigger SQL Script on each of the 250+ application databases.
Is there some way I can create a script to do this for all the databases in the domain.databasename of the SLSYSTEM database.

Thanks so much in advance.

Erland Sommarskog

unread,
Apr 16, 2013, 4:52:36 PM4/16/13
to
The easiest would be to write a small C# program that accepts a file
name as inparameter, reads that file into a varibale and then retrieves the
database name from that domain table, and then for every database runs:

cmd.CommandText = "USE " + dbname
cmd.ExecuteNonQuery();
cmd.CommandText = file_contents;
cmd.ExecuteNonQuery();


--
Erland Sommarskog, SQL Server MVP, esq...@sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx

0 new messages