34,838
社区成员




# --(2)@@identity,scope_identiuty()之间的区别
# /*
# 对于@@identity而言,它返回的是当前会话中任何作用域内的最后插入的一个标识值
# 对于scope_identity()而言,它返回的是当前作用域内插入的标识值
# */
# create table t1
# (
# id int identity(1,1),
# col int
# )
# create table t2
# (
# id int identity(100,1),
# col int
# )
# create trigger tg_t1 on t1
# for insert
# as
# insert into t2 select col from inserted
# go
# insert into t1 select 2
# select @@identity,scope_identity()
#