1。identity 函數中不能用變量作參數
declare @a int
select @a=190
select identity(int,@a,1) as id,* into #temp from tablename
select * from #temp
上述不正確,可以用如下方法
declare @a int
set @a=190
//首先把結構賦值過去
select identity(int,1,1) as id,* into #temp1from tablename where 1=2
//改變初始值
dbcc checkident(#temp1,reseed,@a)
insert into #temp1 select * from tablename
select * from #temp1
2。要想讓自增字段從1開始,可以
dbcc checkident(tablename,reseed,0)