Skip to content
Advertisement

Create or alter trigger if exists

I’m trying to determine withing if If I should create or alter and trigger. My Code is below.

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?

Advertisement

Answer

If you don’t want to the create trigger statement as dynamic SQL, then you can do something like this:

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement