title: T-SQL Incorrect syntax near the keyword 'TRIGGER'
body: <p>I created instead of trigger like that:</p>
  
  <pre><code>CREATE TRIGGER ReadOnlyEvent ON 
  TableName INSTEAD OF INSERT, UPDATE, DELETE AS BEGIN 
  RAISERROR('Tables are read only.', 16, 1 ) ROLLBACK TRANSACTION END;
  </code></pre>
  
  <p>And that code works fine. But when i combine this with 'IF' i got an error:</p>
  
  <pre><code> IF OBJECT_ID ('ReadOnlyEvent', 'TR') IS NULL 
      CREATE TRIGGER ReadOnlyEvent ON
   TableName INSTEAD OF INSERT, UPDATE, DELETE AS BEGIN 
   RAISERROR('Tables are read only.', 16, 1 ) ROLLBACK TRANSACTION END;
  </code></pre>
  
  <blockquote>
    <p>Incorrect syntax near the keyword 'TRIGGER'.</p>
  </blockquote>
  
  <p>I also tryed IF with BEGIN END:</p>
  
  <pre><code>IF OBJECT_ID ('ReadOnlyEvent', 'TR') IS NULL
  BEGIN
      CREATE TRIGGER ReadOnlyEvent ON
      TableName INSTEAD OF INSERT, UPDATE, DELETE AS BEGIN 
      RAISERROR('Tables are read only.', 16, 1 ) ROLLBACK TRANSACTION END;
  END;
  </code></pre>
  
  <p>Why i got this error? :-)</p>