View Single Post
  #5 (permalink)  
Old September 19th, 2006, 03:52 PM
dparsons dparsons is offline
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

You will have to forgive me, its been a long day i misspoke about the SELECT List;

You should be able to do something like this:

Declare @column varchar(255)
Declare @select varchar(255)

Set @select = 'SELECT ' + @column + ' FROM table'
exec(@select)

which should execute the select perfectly.


(If your queries are going to get complex (e.g. over 255 characters) you may want to use an Nvarchar field)
--Stole this from a moderator

I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
Reply With Quote