scope_indentity() 返回插入到同一作用域中(存储过程,.......)的indentity列内的最后一个indentity值
例:
---------------------------
3 liuchunmei
例:
declare @dt table
( _id int identity(1,1),
_name char(10)
)
insert into @dt (_name) values('zhang')
insert into @dt (_name) values('zhu')
insert into @dt (_name) values('liuchunmei')
select * from @dt where _id=scope_identity()
--Results : _id _name( _id int identity(1,1),
_name char(10)
)
insert into @dt (_name) values('zhang')
insert into @dt (_name) values('zhu')
insert into @dt (_name) values('liuchunmei')
select * from @dt where _id=scope_identity()
---------------------------
3 liuchunmei