Return to Snippet

Revision: 54314
at December 20, 2011 04:28 by ezerick


Initial Code
declare @StartNumber int = 1000

insert into Table2 select (ROW_NUMBER() OVER(ORDER BY [field]  DESC)) + @StartNumber AS id, * from Table1

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

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

Initial Title
Auto Incremementing Id for Insert in T-SQL table

Initial Tags
sql

Initial Language
SQL