⌘BABAKOV.NET Let's code!
100% [dark] [ru]

Example of creating a SEQUENCE in MSSQL

Example of creating a SEQUENCE in MSSQL:

CREATE SEQUENCE [dbo].[CardNum] 
 AS [bigint]
 START WITH 1
 INCREMENT BY 1
 MINVALUE -9223372036854775808
 MAXVALUE 9223372036854775807
 CACHE 
GO

This script will create a SEQUENCE CardNum with a type of BIGINT and a starting value of 1 in the current database.

To get a new value value from the SEQUENCE:

set @card_num =  NEXT VALUE FOR [dbo].[CardNum];

To get the current properties properties for the SEQUENCE:

SELECT * FROM sys.sequences WHERE name = \'CardNum\' ;

Comments (0)

No comments yet.

Leave a comment
Comment
Images (up to 5 MB)
Your comment will appear after moderation.