sql server中标识列值突然跳转到1001 [英] Identity column value suddenly jumps to 1001 in sql server

查看:46
本文介绍了sql server中标识列值突然跳转到1001的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 Sql server 2012(Denali).我想知道为什么所有标识列值都从 1001 开始等等.一开始Identity 列从1,2 开始,依此类推,顺利添加标识,但突然跳到1001,1002 以及数据库中包含标识列的所有表.可能是什么原因?请协助.

I am using Sql server 2012(Denali). I wonder why all identity column values start from 1001 and so on. At the beginning Identity column starts from 1,2 and so on and adding identity smoothly, but suddenly it jumps to 1001,1002 and onwards for all the table in the database containing identity column. What could be the reason? Please assist.

推荐答案

Microsoft 已经改变了他们在 SQL Server 2012 中处理标识值的方式,因此您可以在重新启动 SQL Server 后看到记录之间的标识差距实例或您的服务器机器.出现这个id差距可能还有其他原因,可能是安装更新后服务器自动重启.

Microsoft has changed the way they deal with identity values in SQL Server 2012 and as a result of this you can see identity gaps between your records after rebooting your SQL server instance or your server machine. There might be some other reasons for this id gaps, it may be due to automatic server restart after installing an update.

您可以使用以下两种选择

You can use below two choices

  • 使用跟踪标志 272o 这将导致为每个生成的标识值生成日志记录.打开此跟踪标志可能会影响身份生成的性能.

  • Use trace flag 272 o This will cause a log record to be generated for each generated identity value. The performance of identity generation may be impacted by turning on this trace flag.

使用带有 NO CACHE 设置的序列生成器

Use a sequence generator with the NO CACHE setting

在 SQL Server 2012 上设置您期望的跟踪标志 272

Setting Trace Flag 272 on SQL Server 2012 that you are expecting here

打开SQL Server 配置管理器"

Open "SQL Server Configuration Manager"

单击SQL Server 服务";在左窗格中

Click "SQL Server Services" on the left pane

在右侧窗格中右键单击您的 SQL Server 实例名称 -> 默认:SQL Server(MSSQLSERVER)

Right-click on your SQL Server instance name on the right pane ->Default: SQL Server(MSSQLSERVER)

点击属性"

点击启动参数"

关于指定启动参数"文本框类型-T272"

On the "specify a startup parameter" textbox type "-T272"

点击添加"

确认更改

这篇关于sql server中标识列值突然跳转到1001的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆