SCOPE_IDENTITY 和 @@IDENTITY 的差異

這個問題有一陣子一直困擾著我
我的解釋是
1.SCOPE_IDENTITY
是傳回這次影響範圍內的遞增值

2.@@IDENTITY
是傳回這次指令的遞增值

最大的差異可以在兩個TABLE中的新增時,並且有]TRIGGER中發現
中文參考資料內有範例
英文的參考資料則解釋的較清楚

英文參考資料
http://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/

中文參考資料
http://www.dotblogs.com.tw/ajun/archive/2008/04/01/2504.aspx

留言

熱門文章