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

 All Forums
 SQL Server 2008 Forums
 Other SQL Server 2008 Topics
 Alter Column Name based on another field value
 New Topic  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

52325 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  
 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.05 seconds. Powered By: Snitz Forums 2000