Generic Script for Creating Triggers! | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Generic Script for Creating Triggers!


Probably this is a vague question. I need to write a generic script/sp that will generate scripts for existing TRIGGERS from all tables and execute in new database. I think it can be done BUT my problem is how do I do this for all tables at once? Cursor or Dynamic SQL? Just curious, if anyone has suggestion/solution for this?
Name
———
Dilli Grg (1 row(s) affected)
<br />This might be a developer question than DBA. Please feel free to move around.[<img src=’/community/emoticons/emotion-1.gif’ alt=’:)‘ />]<br /><br /><pre id="code"><font face="courier" size="2" id="code"><br /><br />Name<br />——— <br />Dilli Grg <br /><br />(1 row(s) affected)<br /></font id="code"></pre id="code">
Just use a cursor. Below is a link of a script I write what searches an entire server for a word in a script /proc etc. You can lift that logic and put in any code you want http://www.sql-server-performance.com/forum/topic.asp?TOPIC_ID=20826 Michael
MCDBA "The statistics on sanity are that one out of every four persons is suffering from some sort of mental illness. Think of your three best friends — if they’re okay, then it’s you!"

Thanks Mike for the response. My question was more of how to generate trigger scripts from all existing tables than searching for string in a server unless I am missing something. But I can certainly use this in some other requirements though.
Name
———
Dilli Grg (1 row(s) affected)
]]>