It is extremely useful to return the URN, or any other field, of a newly inserted row for a given table in a single query. The OUTPUT clause makes this possible.
insert into MY_TABLE (Field_1, Field_2, Field_3)
OUTPUT Inerted.REF
values (‘Foo’,’Bar’,’Example’)
The above example returns the REF field, which contains auto-incremented urn in MY_TABLE.
Image may be NSFW.
Clik here to view.

Clik here to view.
