SQL Server 2005 query shortcuts

Posted Monday, November 20, 2006 3:04 PM by Maurice
SQL Server 2005 introduced some nice shortcuts for working with queries and identity or GUID key columns. These functions are specially useful if you want to write generic functions without worrying about the key names.
 
Given a table Article with an identity column the following query will retrieve all data and an extra column __pkey__ containing the primary key, whatever the name is.
Select $identity as __pkey__,*FromArticle
 
Replace $identity with $rowguid if you are using GUID primary keys.
 
Enjoy!
 
Filed under:

Comments

# re: SQL Server 2005 query shortcuts

Monday, March 12, 2007 3:27 AM by rajesh jaiswal

retrieve some data from a table and also insert that another table through a query

Leave a Comment

(required) 
(required) 
(optional)
(required)