Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 How to copy triggers...

Author  Topic 

danielc
Starting Member

49 Posts

Posted - 2007-02-08 : 19:20:35
Hello folks,

My question is on copying triggers from one database to another, same server. Now, I know that I can do that using DTS or the Wizard. However, I would like to copy only the triggers to a newly created database. Every year a new database is created with the same schema from last year with no data. Many tables have triggers and I would like to copy those over to the new database. Can I create a script to do this? And how do I start?

Thanks in advance for your help,

Dan

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-02-08 : 22:37:26
use Enterprise Manager to script out the triggers and save it to file. Run the script on the new database


KH

Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2007-02-09 : 03:19:58
http://www.elsasoft.org/tools.htm


www.elsasoft.org
Go to Top of Page

danielc
Starting Member

49 Posts

Posted - 2007-02-09 : 12:18:46
Thank you all for the reply...

We have a lot triggers and saving all of them manually would take to long and i might forget to save some. I would rather like to automate the process by remembering to execute a sproc once a year...

Thank you again,

Dan
Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2007-02-09 : 12:22:30
did you look at the link i posted? it's a cmd line app to script objects in sql server. you could easily automate it by calling from a bat file, scheduled task, whatever.

also the source is available so if all you want to script is the triggers, just modify the app to do that.


www.elsasoft.org
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2007-02-09 : 12:36:03
Sounds like you need a change control process as well



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -