It's not who you are underneath, it's what you do that defines you

SQL 数据库表标识列初始化 DBCC

把ArimaIndexForecastModel这张表的标识列重置为0,前提是这张表执行过删除操作

示例:  dbcc checkident('ArimaIndexForecastModel',reseed,0)

语法:

DBCC CHECKIDENT ( table_name[, { NORESEED | { RESEED [, new_reseed_value ] } } ])[ WITH NO_INFOMSGS ]

table_name 表名,必须包含标识列,否则执行报错
NORESEED  不更改标识列
RESEED  更改标识列为指定值
new_reseed_value  新值
WITH NO_INFOMSGS  不显示执行结果

重置方法:
一、表里有数据
1、DBCC CHECKIDENT ('ArimaIndexForecastModel', NORESEED) 可以确定列中的当前最大值,例如145,然后执行 DBCC CHECKIDENT (table_name, RESEED, 145)
2、直接执行DBCC CHECKIDENT ('ArimaIndexForecastModel', RESEED, 0),然后执行 DBCC CHECKIDENT ('ArimaIndexForecastModel', RESEED) 更正一下,就从表里最后一个值+1开始插入数据了
二、表里没有数据
直接执行DBCC CHECKIDENT ('ArimaIndexForecastModel', RESEED, 0)即可,数字0可以替换成别的数字
posted @ 2013-10-27 23:17  金铭杰  阅读(470)  评论(0编辑  收藏  举报

Brick walls are there for a reason :they let us prove how badly we want things