Questions tagged «sql-server-2005-express»

13
如何以编程方式更改标识列的值?
我有一个MS SQL 2005数据库,其中的表Test带有column ID。ID是一个标识列。 我在此表中有行,并且所有行都有其对应的ID自动递增值。 现在,我想像这样更改此表中的每个ID: ID = ID + 1 但是当我这样做时,我得到一个错误: 无法更新标识列“ ID”。 我已经试过了: ALTER TABLE Test NOCHECK CONSTRAINT ALL set identity_insert ID ON 但这不能解决问题。 我需要在此列设置标识,但是我还需要不时更改值。所以我的问题是如何完成这项任务。
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.