September 11, 2014 at 5:45 am
Hi All,
I have many new tables for which i need to write Insert,Update and delete triggers manually. Is there any way to generate triggers script which takes table name as a input parameter and print/generate trigger's script?
Thanks in Advance.
Regards,
Vijay
September 11, 2014 at 8:38 am
vijay.singh 14112 (9/11/2014)
Hi All,I have many new tables for which i need to write Insert,Update and delete triggers manually. Is there any way to generate triggers script which takes table name as a input parameter and print/generate trigger's script?
Thanks in Advance.
Regards,
Vijay
Yes... just write the generic dynamic SQL to create a table, get the column names from the sys.columns or INFORMATION_SCHEMA.columns, and you're done. I did it for the creation of audit triggers.
If someone makes the suggestion of using a generic CLR or a generic T-SQL trigger that can simply be copied from one table to another, be well advised that they pretty much suck for performance because they have to materialize the INSERTED and DELETED tables to make the trigger work because those tables are out of scope for anything dynamic. It's best to do what you're doing... have code to write hard-coded triggers.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply