--给你个例子 --强制在表中插入标识值 SET IDENTITY_INSERT 表名 ON INSERT tb(id,col) VALUES(10,1) SET IDENTITY_INSERT 表名 OFF
1.先去掉自增长属性, 2.新增完成后, 3.在开启自增长属性. 借楼上的例子 :)SET IDENTITY_INSERT 表名 OFF INSERT tb(id,col) VALUES(10,1) SET IDENTITY_INSERT 表名 ON
if object_id('tb1')is not null drop table tb1 go create table tb1(id int identity(1,1),Name varchar(10)) insert tb1 select 'Stone' insert tb1 select 'Happy' insert tb1 select 'Rick' go set identity_insert tb1 on insert tb1(id,name) values( 10,'Stone') set identity_insert tb1 off insert tb1 select 'Rick' select * from tb1
在插入语句前面加
增量会麻烦些
覆盖的话就先用truncate table tb1 表记录清后再导就ok了
--给你个例子
--强制在表中插入标识值
SET IDENTITY_INSERT 表名 ON
INSERT tb(id,col) VALUES(10,1)
SET IDENTITY_INSERT 表名 OFF
2.新增完成后,
3.在开启自增长属性.
借楼上的例子 :)SET IDENTITY_INSERT 表名 OFF
INSERT tb(id,col) VALUES(10,1)
SET IDENTITY_INSERT 表名 ON
drop table tb1
go
create table tb1(id int identity(1,1),Name varchar(10))
insert tb1 select 'Stone'
insert tb1 select 'Happy'
insert tb1 select 'Rick'
go
set identity_insert tb1 on
insert tb1(id,name) values( 10,'Stone')
set identity_insert tb1 off
insert tb1 select 'Rick'
select * from tb1