Tuesday, March 27, 2012

Easy way to copy Triggers

I'm looking for an easy way to copy triggers from my development database to
my production database without having to copy and paste the trigger to each
table.You could generate a SQL script... e.g. open Enterprise Manager, right-click
a table, choose All Tasks > Generate SQL Script, choose all tables, and make
sure that on the options tab, you select "script triggers"... then you can
just modify the resulting script to only have the triggers, assuming all of
the tables actually exist in the production database.
You could also try using the system tables to generate a script to create
all triggers:
select sc.text + CHAR(13) + CHAR(10) + 'GO'
from
sysobjects so INNER JOIN
syscomments sc ON sc.id = so.id
where so.xtype='tr'
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
"Geoff" <cbsinc@.earthlink.net> wrote in message
news:pcIac.10178$lt2.7981@.newsread1.news.pas.earthlink.net...
> I'm looking for an easy way to copy triggers from my development database
> to
> my production database without having to copy and paste the trigger to
> each
> table.
>

No comments:

Post a Comment