Mainting Identity value across multiple tables

佐手、 提交于 2019-12-05 21:21:26

I have not used it myself but I think you need the new Sequence Object

You would Create a Sequence Object and rather then using Identity values just get the next value from your sequence object.

Create Sequence Object

CREATE SEQUENCE Sqnc_Number_Generator AS INT   --<-- This can be Bigint as well
    START WITH   1  -- Start with value 1
    INCREMENT BY 1  -- Increment with value 1
    MINVALUE  1     -- Minimum value to start is 1
    MAXVALUE  50000 -- Maximum it can go to 5000
    NO CYCLE        -- Do not go above 5000
    CACHE 500        -- Increment 500 values in memory rather than incrementing from IO

Getting Next value

SELECT NEXT VALUE FOR dbo.Sqnc_Number_Generator AS NxtValue;

SQL FIDDLE

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!