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
 Select Question

Author  Topic 

raysefo
Constraint Violating Yak Guru

260 Posts

Posted - 2010-08-13 : 02:30:58
Hi,

I m using MS SQL Server. What i would like to do is,

In table there is a field x having only 1 or 2. In SELECT statement i would like to show ON for 1 and OFF for 2. How can i do this?

Thanks in advance.

Best Regards.

vaibhavktiwari83
Aged Yak Warrior

843 Posts

Posted - 2010-08-13 : 02:34:38
SELECT CASE X WHEN 1 THEN 'ON' WHEN 2 THEN 'OFF' END AS Col_X FROM YourTable

Vaibhav T

To walk FAST walk ALONE
To walk FAR walk TOGETHER
Go to Top of Page

raysefo
Constraint Violating Yak Guru

260 Posts

Posted - 2010-08-13 : 02:39:46
thanks so much.
Go to Top of Page

vaibhavktiwari83
Aged Yak Warrior

843 Posts

Posted - 2010-08-13 : 02:49:01
Welcome

Vaibhav T

To walk FAST walk ALONE
To walk FAR walk TOGETHER
Go to Top of Page
   

- Advertisement -