So the output clause looks like a roadroller to crack a nut if all you want is the Primary Key for the record you just inserted.

- otoh imho no end users should be doing operations on actual tables - they should just have access to tailored views that have 'instead of' triggers that call sp's - the 'insert' sp *could* return a pk, but most cases where you need that should be included in the design of the view and handled by the sp (which also writes an audit trail of course!)

On 09/12/2015 19:32, Stephen Russell wrote:included
Stored procedure that returns @@Identity or scope_identity

http://www.sqlteam.com/article/using-the-output-clause-to-capture-identity-values-on-multi-row-inserts

On Mon, Dec 7, 2015 at 9:49 PM, Kent Belan <[email protected]> wrote:

Hello,

I am inserting records into an SQL table and I need to find out what is the
Primary Key for the record I just inserted.


<snip>

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to