The Problem Solver

Tell me and I will forget
Show me and I will remember
Involve me and I will understand
- Confucius -

Google Ads

This Blog

Syndication

Search

Tags

News





  • View Maurice De Beijer's profile on LinkedIn

Community

Email Notifications

Explore

Archives

SQL Server 2005 query shortcuts
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!
 
Published Mon, Nov 20 2006 15:04 by Maurice
Filed under:

Comments

# re: SQL Server 2005 query shortcuts@ Monday, March 12, 2007 3:27 AM

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