Thursday, August 11, 2011

Using $IDENTITY function

You may have used many different Identity functions like SCOPE_IDENTITY(), @@IDENTITY etc. but have you used $IDENTITY function.

Let us say you have a table where identity property is set in one of the columns.

image

if you run the following query,

image

Following is the result,

image

This means, you don’t have to explicitly mention the identity column instead you can use $IDENTITY.  You can use this for all aggregations ( AVG ($IDENTITY), MAX($IDENTITY) etc) as well as in grouping columns.

No comments:

Post a Comment