Well, you can use SEQUENCE , introduced in SQL Server 2012, brings an identifier generation method
To use it in an insert statement, you first need to create a sequence like this, -
CREATE SEQUENCE dbo.Id_Sequence AS INT START WITH 1 INCREMENT BY 1 MINVALUE 0 NO MAXVALUE
Now use it in the insert statement, like this:
INSERT INTO dbo.Test1 ( orderid , custid , empid ) SELECT NEXT VALUE FOR dbo.Id_Sequence, @custid , @empid
What is it.
source share