In sql server there are two types
of pseudo columns
1. $IDENTITY
2. $ROWGUID
We can think these pseudo columns as alias of identity columns and ROWGUIDCOL columns respectively of any table.
$IDENTITY:
To use this column table must have
identity column. For example we have created a table as follow:
CREATE TABLE tblUser(
ID BIGINT IDENTITY,
[Name] VARCHAR(100)
)
INSERT tblUser VALUES('Scott'),('Greg')
Now
executing following sql query:
SELECT $IDENTITY,[Name]
FROM tblUser
Output:
ID
|
Name
|
1
|
Scott
|
2
|
Greg
|
$ROWGUID:
To use this column table must have ROWGUIDCOL column. For example we
have created a table as follow:
CREATE TABLE tblUser(
ID UNIQUEIDENTIFIER
ROWGUIDCOL DEFAULT(NEWID()),
[Name] VARCHAR(100)
)
INSERT tblUser(Name) VALUES('Scott'),('Greg')
Now
executing following sql query:
This is awesome!! really helpful for me. Thanks for sharing with us. Following links also helped me to complete my task.
ReplyDeletehttp://www.mindstick.com/Blog/358/Usage%20of%20ROWGUID%20and%20IDENTITY%20in%20SQL%20Server
http://social.msdn.microsoft.com/Forums/en-US/lightswitch/thread/e0e0a5e0-82dc-4881-ab8f-64ee4b4a973d