What is scope in SQL Server / how is it defined?
12,387
A scope is a module: a stored procedure, trigger, function, or batch. Therefore, two statements are in the same scope if they are in the same stored procedure, function, or batch.
https://msdn.microsoft.com/en-us/library/ms190315.aspx
Author by
nee21
Updated on June 09, 2022Comments
-
nee21 almost 2 years
I am trying to find documentation on SQL Server where concept of scope is defined. I just want to understand it better.
I had been looking at
scope_identity()
function and it says that@@identity
result andscope_identity()
result will differ in case there are triggers defined which insert records into another table with an identity column.It seems
scope_identity()
decides that insert in the trigger is in different scope. I want to see how that is determined/where it is documented...