如何跳过Identity列的编号?

时间:2022-10-22 09:39:27

Recently I loaded my web app with a back up db. In the back up db the table didn't reached upto my present Identity numbering. I want to skip these numbers from my backup db identity seeding. please help, this is urgent!

最近我用备份数据库加载了我的网络应用程序。在备份数据库中,表格没有达到我目前的身份编号。我想从我的备份数据库身份播种中跳过这些数字。请帮忙,这很紧急!

Or

要么

What will happen if I change the identity seed in the middle?

如果我在中间更改身份种子会怎样?

1 个解决方案

#1


5  

DBCC CHECKIDENT ('yourtablename', reseed, newvalue)

where newvalue is greater than max(currentvalue of identity column)

newvalue大于max(标识列的当前值)

As per your comment "table numbered 1,2,3,4 .Now I want to skip 5,6 and continue with 7,8,9"

根据你的评论“表编号1,2,3,4。现在我想跳过5,6并继续7,8,9”

 DBCC CHECKIDENT ('mytablename', reseed, 7)

#1


5  

DBCC CHECKIDENT ('yourtablename', reseed, newvalue)

where newvalue is greater than max(currentvalue of identity column)

newvalue大于max(标识列的当前值)

As per your comment "table numbered 1,2,3,4 .Now I want to skip 5,6 and continue with 7,8,9"

根据你的评论“表编号1,2,3,4。现在我想跳过5,6并继续7,8,9”

 DBCC CHECKIDENT ('mytablename', reseed, 7)