SEQUENCE in SQL Server 2012


USE TempDB
GO
-- Create sequenceCREATE SEQUENCE dbo.SequenceID AS BIGINT
START 
WITH 3
INCREMENT 
BY 1
MINVALUE 1
MAXVALUE 5
CYCLE
NO CACHE
;GO-- Following will return 3SELECT next value FOR dbo.SequenceID;-- Following will return 4SELECT next value FOR dbo.SequenceID;-- Following will return 5SELECT next value FOR dbo.SequenceID;-- Following will return which numberSELECT next value FOR dbo.SequenceID;-- Clean upDROP SEQUENCE dbo.SequenceID;GO

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: