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
 Renaming Individual Query Results

Author  Topic 

vanmeter
Starting Member

3 Posts

Posted - 2008-10-31 : 13:39:03
I'm pretty new to this and can't figure this one out; I am working in a situation where I can't go in and modify returned values when I run a query, but I need them to say something else for consistency. Like for city, the database might have:
HOUSTON TX
BOISE IDAHO
LOS ANGELES

And I need to be able, when I pull those results in one specific query, to have them come out as:

Houston, TX
Boise, ID
Los Angeles, CA

Is this possible? Again, all I can do is run a query, I can't change anything in the database, so the renaming will have to happen within the statement if it's possible. Thanks!

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-31 : 13:42:44
whats the basis for this renaming? changing case of first word is ok. but didnt understand logic behind addind ID for IDAHo and CA for Los Angeles. do you have this mapping stored some where?
Go to Top of Page

vanmeter
Starting Member

3 Posts

Posted - 2008-10-31 : 13:54:16
Well, we have data that's been entered in various ways over the years, and I want to be able in an online dropdown to be able to control the text that's seen. Just changing case isn't really enough; this isn't actual data I posted, it's just the type of thing I'm looking to do with several types of columns. Essentially, can I pull the individual fields of one column in a database and assign my own names to them each?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-31 : 13:58:17
that would be tedious unless you've a table storing the original names with ones you're wishing to replace with. Otherwise you should have a common pattern for deriving the reqd name from value in table. like changing case of first word then taking first and last leeter of next,... but if no such pattern is there, then its really tedious.
Go to Top of Page

vanmeter
Starting Member

3 Posts

Posted - 2008-10-31 : 14:24:11
There are only a few values per query, but I gather this isn't easily done!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-31 : 14:28:22
not unti you have a predefined pattern or store mapings already.
Go to Top of Page
   

- Advertisement -