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)
 Changing value in Select statement

Author  Topic 

suchiate
Starting Member

33 Posts

Posted - 2007-03-10 : 08:07:57
Hey guys,

I would like to find out if I could change the values due to certain conditions in a select statement without using cursors such that:

I have a bit column, name bitAct for example, if it is true, i wanna display Activated instead of true and Deactivated instead of false.

Thanks lot in advance. Hope you guys can help me out.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-03-10 : 08:14:50
[code]
select case when bitAct = 1 then 'Activated'
when bitAct = 0 then 'Deactivated'
else ''
end
from yourtable
[/code]


KH

Go to Top of Page

spejbl
Starting Member

28 Posts

Posted - 2007-03-10 : 08:16:23
or
SELECT
CASE bitAct
WHEN 0 THEN 'Deactivated'
WHEN 1 THEN 'Activated'
ELSE ''
END
FROM dbo.YourTable
--
kb
http://kbupdate.info/
Go to Top of Page

suchiate
Starting Member

33 Posts

Posted - 2007-03-10 : 08:23:18
Thanks alot guys, it helped big time =)
Go to Top of Page
   

- Advertisement -