title: SQL Server Insert values from one table to another, and increment a column value while doing so
body: <p>I have two tables in my database. Table T1 contains merchandise information, like Name, PIN, manufacturer and so on. 
  Table T2 is like an entity table that needs to be updated sometimes, so I need to write a script for its update.</p>
  
  <p>What I'm doing is selecting all entities from T1, who's ID is not in T2 and making a new table from it.</p>
  
  <pre><code>CREATE TABLE #TEMP
  (
    IdMerc INT
    Code Varchar(200)
  )
  
  INSERT INTO #TEMP (IdMerc, Code)
  SELECT [IdMerchandise], CONCAT([manufact],'.',[city])
  FROM T1
  WHERE T1 NOT IN (SELECT [IdMerchandise] 
                   JOIN T1 ON [IdMerchandise]=[IdEnt]
                   COLLATE SQL_Latin1_General_CP1_CI_AS)
  </code></pre>
  
  <p>Now, I need to insert values from #TEMP to T2, but T2 has this <code>[IdEnt]</code> column that needs to be an incremental value. My T2 already has a primary key <code>[RowId]</code></p>
  
  <p>My question is, how do I insert all data from #TEMP to T2, but with incrementing the [IdEnt] column while inserting? I already tried Insert-Select with incrementing the IdEnt but it throws an error that says I can't add an increment statement to select and insert.</p>