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 2008 Forums
 Transact-SQL (2008)
 Change a number to a word

Author  Topic 

laurillo87
Starting Member

4 Posts

Posted - 2014-04-15 : 13:39:27
Hello

I want to change a number to a word, let me show my query

SELECT Ready, Tired FROM PEOPLE

the table is like these

Ready Tired
1 0
0 1

I need to write in the table result a Yes for 1 and No for 0

the table have to be like these

Ready Tired
YES NO
NO YES

Some here know if what i want to do it's posible?

djj55
Constraint Violating Yak Guru

352 Posts

Posted - 2014-04-15 : 13:45:33
In this case you can use the CASE statement
SELECT CASE Ready WHEN 1 THEN 'TRUE' ELSE 'FALSE' END AS Ready, CASE Tried WHEN 1 THEN 'TRUE' ELSE 'FALSE' END AS Tried FROM PEOPLE


djj
Go to Top of Page

laurillo87
Starting Member

4 Posts

Posted - 2014-04-15 : 13:58:35
djj55, thank you very much, thats the solution, It worked as I needed

quote:
Originally posted by djj55

In this case you can use the CASE statement
SELECT CASE Ready WHEN 1 THEN 'TRUE' ELSE 'FALSE' END AS Ready, CASE Tried WHEN 1 THEN 'TRUE' ELSE 'FALSE' END AS Tried FROM PEOPLE


djj

Go to Top of Page
   

- Advertisement -