SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 concordinate query
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

shanmugaraj
Posting Yak Master

219 Posts

Posted - 04/23/2013 :  06:17:36  Show Profile  Send shanmugaraj a Yahoo! Message  Reply with Quote

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
Flowing Fount of Yak Knowledge

India
2223 Posts

Posted - 04/23/2013 :  06:54:53  Show Profile  Reply with Quote

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 - 04/23/2013 :  07:04:35  Show Profile  Send shanmugaraj a Yahoo! Message  Reply with Quote
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
Flowing Fount of Yak Knowledge

India
2223 Posts

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




--
Chandu
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000