获取自增列函数DENT_CURRENT、@@IDENTITY 和 SCOPE_IDENTITY区别
1.用法:
dent_current('tablename') ---其返回表tablename的标识值(或自增列主键)
@@identity 全局变量,返回表标识值
scope_identity() 返回当前会话的标识值
eg.
use [data]--数据库名
go
select IDENT_CURRENT('table2') as 'ident',SCOPE_IDENTITY()as 'scope',@@IDENTITY as 'identity'
go
结果:
ident | scope | identity |
1001 | NULL | NULL |