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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Change Row Value

Author  Topic 

u2envy1
Yak Posting Veteran

77 Posts

Posted - 2007-06-01 : 06:21:14
How do I go about in changing the row value in a SELECT query.
Eg. If I have a row Status. If that row returns Number like 1,2,3,4,5, & 6. When I do the Select query. All rows that return 1 must have a value of Canceled, 2= OnHold, 3= InQuery & so on.
How can this be done in SQL 2000

bpgupta
Yak Posting Veteran

75 Posts

Posted - 2007-06-01 : 07:46:47

select case status when 1 then 'cancelled'
when 2 then 'onhold'
when 3 then 'Inquery'
---

Else
'Nothing'
from tablename
Go to Top of Page

pbguy
Constraint Violating Yak Guru

319 Posts

Posted - 2007-06-01 : 07:54:27
row is returning numbers???? do you mean comma separated values

post some and data and required output

--------------------------------------------------
S.Ahamed
Go to Top of Page

u2envy1
Yak Posting Veteran

77 Posts

Posted - 2007-06-01 : 08:11:00
row is returning numbers.
SELECT * FROM Status

RETURN
--------

UserID Current_Status
John 1
Peter 2
Paul 3

It should return


UserID Current_Status
John Cancelled
Peter OnHold
Paul InQuery


Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-06-01 : 08:16:03
quote:
Originally posted by bpgupta


select case status when 1 then 'cancelled'
when 2 then 'onhold'
when 3 then 'Inquery'
---

Else
'Nothing'
end
from tablename



Madhivanan

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

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-06-01 : 08:18:51
quote:
Originally posted by u2envy1

row is returning numbers.
SELECT * FROM Status

RETURN
--------

UserID Current_Status
John 1
Peter 2
Paul 3

It should return


UserID Current_Status
John Cancelled
Peter OnHold
Paul InQuery





You can use modified code of pbgupta

Madhivanan

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

u2envy1
Yak Posting Veteran

77 Posts

Posted - 2007-06-01 : 08:54:46
Thanks peeps
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-06-01 : 09:01:23
quote:
Originally posted by u2envy1

Thanks peeps

Does this mean "Thanks People"?

Madhivanan

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

- Advertisement -