title: SQL Server: preventing manual insert into a column controlled by a sequence
body: <p>I have a <code>Sequence</code> object set on one of our databases with an increment of 1, that we are currently using as the primary key for two of our tables to ensure uniqueness across them both. This is controlled via the following constraint on the tables:</p>
  
  <pre><code>ADD CONSTRAINT SEQ_MySequence DEFAULT (NEXT VALUE FOR dbo.SEQ_sID) FOR ID;
  </code></pre>
  
  <p>We want to prevent a user from manually inserting data into this column, but we cannot find a reliable method to do so. A trigger seems like the obvious choice; however AFTER INSERT triggers execute after constraints are fired and thus the below does not work:</p>
  
  <pre><code>CREATE TRIGGER BlockInsert ON MyTable
  AFTER INSERT
  AS
     IF (SELECT ID FROM inserted) IS NOT NULL
     BEGIN
         ROLLBACK
  END
  </code></pre>
  
  <p>Does anyone have any ideas?</p>