469,138 Members | 1,384 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,138 developers. It's quick & easy.

Problem with replace function

Hi,

Please find the below scenario

Original Table

course branch_exist
BY 0
UI 1
PO 1
LI 0
MK 1
select REPLACE(branch_exist,1,'yes') as branch from university;

displays

course branch_exist
BY 0
UI Yes
PO Yes
LI 0
MK Yes
What i need is
course branch_exist
BY No
UI Yes
PO Yes
LI No
MK Yes
Sql-Server replace function only accepts three arguments, any
suggestions will be greatly welcomed!

Apr 9 '07 #1
3 2425
kb
What i need is:
course branch_exist
BY No
UI Yes
PO Yes
LI No
MK Yes
select
CAST branch_exist
WHEN 1 THEN 'yes'
WHEN 0 'no'
ELSE '?' END as branch
from university;

--
Tom
http://kbupdate.info/ | http://suppline.com/
Apr 9 '07 #2
kb
Oops, typo happens. Right version is:

select
CASE branch_exist
WHEN 1 THEN 'yes'
WHEN 0 THEN 'no'
ELSE '?'
END as branch
from university;
--
Tom
http://kbupdate.info/ | http://suppline.com/
Apr 9 '07 #3
On Apr 9, 5:37 pm, "kb" <a...@kbupdate.infowrote:
Oops, typo happens. Right version is:

select
CASE branch_exist
WHEN 1 THEN 'yes'
WHEN 0 THEN 'no'
ELSE '?'
END as branch
from university;

--
Tomhttp://kbupdate.info/|http://suppline.com/
Hi Kb,

Thanks you !
Apr 9 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by tangus via DotNetMonster.com | last post: by
7 posts views Thread by Kamal | last post: by
3 posts views Thread by hugo | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.