sql,server中的默认列 [英] default column in sql,server
本文介绍了sql,server中的默认列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果删除删除行号6的表,则该表具有一列作为标识"列
标识列的种子值为6,那么如果在表中插入新行,则
如何在身份列中插入相同的数字6?
我在Google上尝试过,但我可以得到它.
请让我知道.
Hi,
I have table with one column as Identity column, if I delete a row number 6 which
has Identity column seed value as 6 then if insert a new row in the table then
how can I insert same number 6 in the identity column?
I tried in google but I could get it.
Please let me know.
推荐答案
您将必须使用SET IDENTITY_INSERT方法
You will have to use the SET IDENTITY_INSERT method
SET IDENTITY_INSERT OFF
INSERT INTO table1 (ID, Field1) VALUES (6,'test')
SET IDENTITY_INSERT ON
希望这只是一次修复.我不建议您定期进行此操作.
请参考 http://msdn.microsoft.com/en-us/library /aa259221(v=sql.80).aspx [ ^ ]
Hopefully this is just a one-time fix. I would not suggest having regular processes that do this.
Refer to http://msdn.microsoft.com/en-us/library/aa259221(v=sql.80).aspx[^]
如果nr 6是最后一条记录,并且(重新)插入数据,您也可以使用
if nr 6 is the last record and (re-)inserting data you can also use
DBCC CHECKIDENT (yourtable, reseed, 5)
这篇关于sql,server中的默认列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文