Get all the triggers in a database
SELECT *
FROM sys.triggers
Get all the triggers with tablename in a database
SELECT
TAB.name as Table_Name
, TRIG.name as Trigger_Name
FROM [sys].[triggers] as TRIG
inner join sys.tables as TAB
on TRIG.parent_id = TAB.object_id
trigger example
ALTER trigger [jupsoft].[keepDeletedRecords] on [jupsoft].[DAMS_Mst_Batch] for Delete
as
begin
insert into tblMirror_DAMS_Mst_Batch (BatchId,FranchaiseCode,CourseId,BatchCode,StartDate,Flag,DeletedTime)
select d.BatchId,d.FranchaiseCode,d.CourseId,d.BatchCode,d.StartDate,d.Flag,GetDate() from DELETED d
END
SELECT *
FROM sys.triggers
Get all the triggers with tablename in a database
SELECT
TAB.name as Table_Name
, TRIG.name as Trigger_Name
FROM [sys].[triggers] as TRIG
inner join sys.tables as TAB
on TRIG.parent_id = TAB.object_id
trigger example
ALTER trigger [jupsoft].[keepDeletedRecords] on [jupsoft].[DAMS_Mst_Batch] for Delete
as
begin
insert into tblMirror_DAMS_Mst_Batch (BatchId,FranchaiseCode,CourseId,BatchCode,StartDate,Flag,DeletedTime)
select d.BatchId,d.FranchaiseCode,d.CourseId,d.BatchCode,d.StartDate,d.Flag,GetDate() from DELETED d
END
No comments:
Post a Comment