Skip to content

Instantly share code, notes, and snippets.

@jhleath
Created June 17, 2010 14:41
Show Gist options
  • Save jhleath/442210 to your computer and use it in GitHub Desktop.
Save jhleath/442210 to your computer and use it in GitHub Desktop.
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
BEGIN TRANSACTION;
Declare @counter int
select @counter = counterID from myTable order by counterID asc
select @counter = @counter + 1
INSERT INTO myTable (counterID) VALUES (@counter)
Select @counter as newCounterID
COMMIT TRANSACTION;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment