读书人

存储过程中的set identity_insert lt;ta

发布时间: 2012-01-06 22:55:18 作者: rapoo

存储过程中的set identity_insert <table> on的作用?
set identity_insert <table> on的作用?
请老师解释一下!
谢谢了!!
给分的!!

[解决办法]
create table test(id int identity(1,1), value int)
go

insert test(id, value) select 2,3
/*
服务器: 消息 8101,级别 16,状态 1,行 1
仅当使用了列的列表,并且 IDENTITY_INSERT 为 ON 时,才能在表 'test ' 中为标识列指定显式值。
*/
go

set identity_insert test on
go

insert test(id, value) select 2,3
/*
(所影响的行数为 1 行)
*/
set identity_insert test off
go

select * from test
/*
idvalue
22
*/

drop table test

读书人网 >SQL Server

热点推荐