How to retrieve the auto-increment identity value by using OUTPUT clause of Insert
项目中经常会用到IDENTITY(1,1) 这种自增长ID的方式。根据@@identity、scope_identity()、IDENT_CURRENT('tablename')函数的区别分析,这三种方式要么不能准确返回当前表的Id,要么存在并发安全隐患。其实自从2005版本以后,SQL Server 就提供了一种更好的方式从Insert的执行中返回受影响行的结果,即OUTPUT 语句。相比于前者...
原创
2019-12-10 13:45:46 ·
224 阅读 ·
0 评论