Skip to content

Instantly share code, notes, and snippets.

@alevyinroc
Last active February 6, 2020 00:06
Show Gist options
  • Select an option

  • Save alevyinroc/00501e9edd7825a799d6f2e46f09c8f9 to your computer and use it in GitHub Desktop.

Select an option

Save alevyinroc/00501e9edd7825a799d6f2e46f09c8f9 to your computer and use it in GitHub Desktop.
CREATE TABLE SequenceHolder (
id INT identity(1, 1)
,BecauseINeedSomething BIT DEFAULT 0
);
CREATE OR ALTER PROCEDURE GetNextNumberTable
AS
BEGIN
DECLARE @newid INT;
INSERT INTO SequenceHolder (BecauseINeedSomething)
VALUES (0);
SET @newid = SCOPE_IDENTITY();
DELETE
FROM SequenceHolder
WHERE id = @newid;
SELECT @newid;
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment