Identity increment is jumping in SQL Server database

前端 未结 6 1544
夕颜
夕颜 2020-11-21 06:47

In one of my tables Fee in column \"ReceiptNo\" in SQL Server 2012 database identity increment suddenly started jumping to 100s instead of 1 depending on the fo

6条回答
  •  生来不讨喜
    2020-11-21 07:11

    From SQL Server 2017+ you could use ALTER DATABASE SCOPED CONFIGURATION:

    IDENTITY_CACHE = { ON | OFF }

    Enables or disables identity cache at the database level. The default is ON. Identity caching is used to improve INSERT performance on tables with Identity columns. To avoid gaps in the values of the Identity column in cases where the server restarts unexpectedly or fails over to a secondary server, disable the IDENTITY_CACHE option. This option is similar to the existing SQL Server Trace Flag 272, except that it can be set at the database level rather than only at the server level.

    (...)

    G. Set IDENTITY_CACHE

    This example disables the identity cache.

    ALTER DATABASE SCOPED CONFIGURATION SET IDENTITY_CACHE=OFF ;
    

提交回复
热议问题