1 create table tblInsert
 2 (
 3     id int identity(1,1) primary key,
 4     name nvarchar(10)
 5 );
 6 
 7 insert into tblInsert(name) values('张三');
 8 
 9 select * from tblInsert;
10 
11 insert into tblInsert(name) values('李四');
12 select @@IDENTITY;--方式一
13 
14 -- 使用inserted临时表   方式二
15 insert into tblInsert(name) output inserted.id values('王五');

 

posted on 2014-07-26 23:02  努力--坚持  阅读(321)  评论(0)    收藏  举报