I'm trying to determine withing if If I should create or alter and trigger. My Code is below.
IF OBJECT_ID(N'Sales.bonus_reminder', N'TR') IS NOT NULL
ALTER TRIGGER Sales.bonus_reminder
ON Sales.SalesPersonQuotaHistory
AFTER INSERT
AS RAISERROR ('Notify Compensation', 16, 10);
else
CREATE TRIGGER Sales.bonus_reminder
ON Sales.SalesPersonQuotaHistory
WITH ENCRYPTION
AFTER INSERT, UPDATE
AS RAISERROR ('Notify Compensation', 16, 10);
The errors I'm getting are :
- Incorrect syntax near else
- Create trigger should be the only statement in batch.
How this code should look like?