Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 concordinate query

Author  Topic 

shanmugaraj
Posting Yak Master

219 Posts

Posted - 2013-04-23 : 06:17:36

i need to have the column name column comming from the parameter
i am unable to pass the parameter in my select query below

declare @column_name varchar(50)
set @column_name = 'format_type_name'
select + @column_name + from Format_type

THANKS
SHANMUGARAJ
nshanmugaraj@gmail.com

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-04-23 : 06:54:53

declare @column_name varchar(50)
set @column_name = 'format_type_name'
DECLARE @sql VARCHAR(500) = 'select '+ @column_name +' from Format_type '
EXEC (@sql)



--
Chandu
Go to Top of Page

shanmugaraj
Posting Yak Master

219 Posts

Posted - 2013-04-23 : 07:04:35
is it possible to create the select query without using
DECLARE @sql VARCHAR(500) =

THANKS
SHANMUGARAJ
nshanmugaraj@gmail.com
Go to Top of Page

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-04-23 : 07:23:39
declare @column_name varchar(50)
set @column_name = 'format_type_name'
EXEC( 'select '+ @column_name +' from Format_type ')




--
Chandu
Go to Top of Page
   

- Advertisement -