nycgags (3/22/2013)
peter.row (2/24/2011)
Why use the output syntax, table variable and dynamic sql?Wouldn't the following be simpler (no permissions issue on table if user running it only has access to SP either) :
insert into ...
set @outputId = scope_identity()
This was my original thought as well, maybe I am missing something.
The scope_identity function has been known to generate incorrect values at times (when queries make use of parallel execution plans). Refer to this link for more information -->
Ajit Ananthram
Blog - http://ajitananthram.wordpress.com