DESCRIPTION:
This procedure produces a SELECT statement which explicitly lists all fields for 'tablename' with fieldname and alias as the column name. The SELECT it produces is ready to run or if you need to join several tables just copy the column names off the SELECT it generates. I use this a lot when I create INNER JOINS with several tables and want to put the data into #temp tables which require unique field names.
LIMITATIONS:
* The way it's written it won't run in master database as a sp_ proc
INSTRUCTIONS:
_SELECT 'tablename', 'alias'
EXAMPLE: (using pubs database)
_select 'authors', 'a'
Please feel free to modify to fit your needs.
2007-10-02 (first published: 2002-06-20)
15,451 reads