Reputation: 379
How can we create sequence in SQL Server? I am creating like this
CREATE SEQUENCE counter
AS INT
MINVALUE 1
NO MAXVALUE
START WITH 1;
but getting below error
Msg 343, Level 15, State 1, Line 1
Unknown object type 'SEQUENCE' used in a CREATE, DROP, or ALTER statement.
Thanks in advance
Upvotes: 2
Views: 7846
Reputation: 230
CREATE SEQUENCE CountBy1 START WITH 1 INCREMENT BY 1 ; SELECT next value for CountBy1
In SQL Server 2012 above is the syntax to create and consume created sequence.
Upvotes: 6