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
 SQL Server 2008 Forums
 Other SQL Server 2008 Topics
 Alter Column Name based on another field value
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

14 Posts

Posted - 05/22/2013 :  15:30:19  Show Profile  Reply with Quote
I'm not sure if I can do this.... I'm trying to change the column heading based on the value of another field.

Something like this:

SELECT Other AS 'Other (describe):' + [OtherText]

The value of Other is "X"
The value of OtherText is "Football"

So the column heading would look like: "Other (describe): Football"
The value would be "X"

... I know there are much better ways of doing this, just we don't have the option of changing the table format.

The Select statement would only ever return one single record.

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 05/23/2013 :  00:59:19  Show Profile  Reply with Quote
you cant do this in t-sql unless you use dynamic sql. My guess is this for a reporting need and there are much easier ways to achieve this at your reporting tool end. For example SSRS supports writing expressions for column headers and I would highly recommend doing it at front end if at all possible.

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