I have one Trigger called dbo.SendMail and multiple database, not all database have the trigger dbo.SendMail.
I am using FluentMigrator to manage database versions and i want to do something like below
IF EXISTS (SELECT * FROM sys.triggers WHERE object_id = OBJECT_ID(N'[dbo].[SendMail]'))
BEGIN
ALTER TRIGGER [dbo].[SendMail]
ON [dbo].[Notification]
FOR INSERT
AS
BEGIN
some sql code
END
END
it is giving me error Incorrect syntax near begin, Expecting EXTERNAL.
is there any way to achieve this ?
Thanks in advance.
Try this: