Here is a cool way to output the results of any DML statement (I am using the INSERT statement in my example) using the OUTPUT statement. Why would anyone want to do this? Frankly it depends on what you need to do with the output of the DML statement. One of the ways I use OUTPUT is to get the new value of an identity column. Although most documentation tells you to use the syntax OUTPUT … INTO <@table_variable>, what happens if you need to wrap this statement into a dynamic query and use the EXEC command in a nested… read more →
