SQL修改自動增長列ID號從1開始
阿新 • • 發佈:2018-11-22
方法一: 刪除原來的欄位重新新增
Alter table talbeName Drop Column ColumnName
Alter table talbeName Add ColumnName Int IDENTITY(1,1)
方法二: 使用命令進行修改
dbcc checkident('test',reseed,0)
檢查自動增加ID: dbcc checkident (表名TableName)
建表事例
create table tb(id int identity ( 1 , 1 ),name varchar ( 10 )) insert into tb(name) select ' abc ' insert into tb(name) select ' sfd ' insert into tb(name) select ' efawe ' insert into tb(name) select ' asdf2 ' insert into tb(name) select ' efw ' insert into tb(name) select ' afsd ' insert into tb(name) select ' asdf2 ' insert into tb(name) select ' 2fsf ' insert into tb(name) select ' cawe ' insert into tb(name) select ' sdf2qe ' go select * from tb
來源1:http://soft-development.iteye.com/blog/792088
來源2:https://blog.csdn.net/yanwu616/article/details/2874345?utm_source=blogxgwz8