How can I Create a Trigger that will be nested within T-SQL or another trigger? Thanks for any help!
Create Trigger within T-SQL statement
Collapse
X
-
-
I'm basically checking to see if a trigger exists and if it doesn't then I'm gonna get an email and I want to create that trigger. Any ideas? Check my code below:Originally posted by debasisdasWhat exactly you are trying to achieve by writing a nested trigger ?
Declare @Body as varchar(125)
Declare @NumRecs as numeric(9)
select
@NumRecs = COUNT(name)
from
dbo.sysobjects
where
OBJECTPROPERTY( id, N'IsTrigger') = 1 and name = 'TR_JUNK2'
select @NumRecs
Set @Body = 'Trigger TR_SO1_TO_CHANG E_LOG missing from table SO1_SOEntryHead er'
IF @NumRecs < 1
BEGIN
EXEC CDO_SendMail 'MyEmail@email. com', @Body, 'Missing Trigger'
CREATE TRIGGER [TR_JUNK2] ON [dbo].[SO9_TEST] FOR DELETE
AS
select '1'
ENDComment
Comment