在做一些特殊项目的时候,可能会遇到在自增长的数据库中插入数据,如果按照普通SQL语句是不能实现的,下面给出具体的SQL:
//自动增长的插入
/**//*创建表*/
create table teacher
(
id int identity(1,1) primary key not null,
name varchar(20)
)
select * from teacher
/**//*关闭自增长*/
SET IDENTITY_INSERT teacher on
insert into teacher(id,name) values(2000,'guo')
/**//*打开自增长*/
IDENTITY_INSERT teacher off
insert into teacher(name) values('guo')