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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Assign return of a query as a column name
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

19 Posts

Posted - 02/04/2014 :  10:32:43  Show Profile  Reply with Quote
Is there a way to achieve that? I have a query with a subquery and I want to assign the return from the query as a column name in the subquery.

something like that where WorkDay is the return from the main query

as Convert(Varchar(10),WorkDay,110)

Edited by - lio1972 on 02/04/2014 10:36:16

Premature Yak Congratulator

22864 Posts

Posted - 02/22/2014 :  11:50:16  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
You need to use dynamic SQL. But why do you want to do this?


Failing to plan is Planning to fail
Go to Top of Page

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 02/23/2014 :  03:07:31  Show Profile  Reply with Quote
Sounds like attempt is for creating some kind of crosstab logic. If that is the case use PIVOT

SQL Server MVP
Go to Top of Page
  Previous Topic Topic Next 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.02 seconds. Powered By: Snitz Forums 2000