select top 10 ID=Identity(int,1,1),val=left(newid(),6) into A from syscolumns a,syscolumns b delete from A where ID=5 create table B(ID int identity(1,1),val varchar(6)) insert into B select val from A drop table A exec sp_rename N'B',N'A' select * from Adrop table A,B
lz使用管理工具,将id停了,手动修改,之后再开启,会继续增长
比如 这是数据库中一个自动编号字段 [Id] [int] IDENTITY(1,1) NOT NULL, 怎样修改 可以让它自动重置!
LZ请查查ROW_NUMBER()这个东东的信息.. Select ROW_NUMBER() OVER (order by id DESC )as OrderId,* from tb
在SQLSERVER中的语句如下:
1. truncate table tablename 清空
2. DBCC CHECKIDENT (tablename,reseed,1)要重置自动编号,就必须清理表内容,然后执行第二句,使得自动编号从1开始
delete from A where ID=5
create table B(ID int identity(1,1),val varchar(6))
insert into B select val from A
drop table A
exec sp_rename N'B',N'A'
select * from Adrop table A,B
[Id] [int] IDENTITY(1,1) NOT NULL,
怎样修改 可以让它自动重置!
Select ROW_NUMBER() OVER (order by id DESC )as OrderId,* from tb