title: How to Retrieve the Identity column value in an insert trigger SQL Server
body: <p>I have two tables that are identical except one has an identity column and the other doesn't. Instead the second table uses the value of the identity column from the first table. I thought I would insert into the second table as a trigger when a record is inserted into the first table. I cannot seem to get syntax right. </p>
  
  <p>Null is being returned from the identity column @EDVisitId.</p>
  
  <pre><code>ALTER TRIGGER [dbo].[trgInserterrEDVisitOriginal] ON [dbo].[errEDVisit]
  AFTER INSERT
  AS
  
  
  --Name:  Bob Avallone
  --Date:  6-15-2017
  --
  --  The purpose of this trigger is to insert a record into errEDVisitOriginal
  --  whenever a new errEDVisit is inserted.
  
  --XXXXXXXXXX
  
  
  
      declare @EDVisitId  int
      declare @SubmissionControlID INT
  
  
  Select  @EDVisitId = EDVisitID from inserted
  SELECT @SubmissionControlID = SubmissionControlID  from Inserted
  
  
    Begin
  
  Insert Into errEDVisitOriginal (EDVisitId, SubmissionControlID)
  
  VALUES (@EDVisitId, @SubmissionControlID )
  
  
  
  End
  </code></pre>