在我的SQL数据库中,我运行了以下脚本来清理数据并重置标识列
-- disable referential integrity
EXEC sp_MSForEachTable 'ALTER TABLE ? NOCHECK CONSTRAINT ALL'
GO
EXEC sp_MSForEachTable 'DELETE FROM ?'
GO
-- enable referential integrity again
EXEC sp_MSForEachTable 'ALTER TABLE ? CHECK CONSTRAINT ALL'
GO
EXEC sp_MSforeachtable @command1 = 'DBCC CHECKIDENT(''?'', RESEED, 1)'
Go
我收到以下消息,
Checking identity information: current identity value 'NULL'.
DBCC execution completed. If DBCC printed error messages, contact your system administrator.
Checking identity information: current identity value '1'.
DBCC execution completed. If DBCC printed error messages, contact your system administrator.
Checking identity information: current identity value '1'.....
我想所有表格都在打印信息。标识已重置,数据已删除。我需要担心这个消息吗?
否
创建表t1(col1 int identity(1,1),col2 int)
插入t1选择1
插入t1选择2
输入t1选择3
从t1删除DBCC CHECKIDENT(t1,RESEED,1)
正在检查标识信息:当前标识值"3",当前列值"1">
DBCC执行完成。如果DBCC打印了错误消息,请与系统管理员联系。
这就像系统预定义的消息一样,只有计数器会不同(在上面显示的示例中,它是"3"(当前身份)和"1"(目标身份号)