April 7, 2016 at 10:35 am
How do you generate a Script for all Triggers on a Table?
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
April 7, 2016 at 10:41 am
SSMS Options-Scripting. Scroll down and triggers is one of the options that is OFF by default. I ALWAYS turn this on, along with indexes and a few others.
After you turn one the things you want, just right-click on a table and script as create to new window or clipboard an VOILA!
Best,
Kevin G. Boles
SQL Server Consultant
SQL MVP 2007-2012
TheSQLGuru on googles mail service
April 7, 2016 at 10:59 am
TheSQLGuru (4/7/2016)
SSMS Options-Scripting. Scroll down and triggers is one of the options that is OFF by default. I ALWAYS turn this on, along with indexes and a few others.After you turn one the things you want, just right-click on a table and script as create to new window or clipboard an VOILA!
Sweet, thank you!
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
April 7, 2016 at 11:03 am
No worries mate. I sure wish those were on by default!
Best,
Kevin G. Boles
SQL Server Consultant
SQL MVP 2007-2012
TheSQLGuru on googles mail service
April 7, 2016 at 1:27 pm
One can view the Trigger definitions by querying syscomments view.
You can sys.objects to get all the triggers.
April 7, 2016 at 2:01 pm
jay81 (4/7/2016)
One can view the Trigger definitions by querying syscomments view.You can sys.objects to get all the triggers.
The system view sys.triggers will work as well.
April 7, 2016 at 10:25 pm
Database> Tasks> Generate Scripts > Next > Next
On Choose Script Options UI, under Table/View Options Heading, set Script Triggers to True.
February 17, 2023 at 12:14 pm
You can get it from system views:
Example:
select
so.name, st.name, sc.text
from sys.triggers st
inner join sysobjects so on st.parent_id = SO.id
inner join syscomments sc on st.object_id = sc.id
where so.name ='<TableName>'
February 17, 2023 at 3:35 pm
You can get it from system views:
Example:
select
so.name, st.name, sc.text
from sys.triggers st inner join sysobjects so on st.parent_id = SO.id inner join syscomments sc on st.object_id = sc.id where so.name ='<TableName>'
You posted an answer to a 7 year old post. There's nothing wrong with that... just wanted to let you know because no one from the original post might respond.
Also, consider not using views that have been deprecated since 2005. 😉
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply