Auto Incremementing Id for Insert in T-SQL table


/ Published in: SQL
Save to your folder(s)

This code allows you to create an ID field value for inserts into a table that does not auto increment itself


Copy this code and paste it in your HTML
  1. DECLARE @StartNumber INT = 1000
  2.  
  3. INSERT INTO Table2 SELECT (ROW_NUMBER() OVER(ORDER BY [FIELD] DESC)) + @StartNumber AS id, * FROM Table1

URL: http://snipplr.com/login/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.