Created
March 17, 2016 11:41
-
-
Save sqlsimon/0edb11da994421f6c886 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE SCHEMA [common] AUTHORIZATION [dbo] | |
CREATE TABLE [common].[sequence_test_id] | |
( | |
sequence_id bigint identity(1,1) | |
,CONSTRAINT [pk_sequence_test_id] PRIMARY KEY (sequence_id) | |
) | |
GO | |
IF OBJECT_ID('') IS NULL | |
EXEC ('CREATE PROCEDURE [common].[usp_generate_test_id] AS SELECT 1') | |
GO | |
CREATE PROCEDURE [common].[usp_generate_test_id] | |
AS | |
BEGIN | |
SET NOCOUNT ON | |
DECLARE @sequence_value bigint | |
INSERT INTO [common].[sequence_test_id] DEFAULT VALUES | |
SET @sequence_value = SCOPE_IDENTITY() | |
DELETE FROM [common].[sequence_test_id] WITH (READPAST) | |
RETURN @sequence_value | |
END; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment