471,607 Members | 2,481 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,607 software developers and data experts.

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 2463
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 leo001 | last post: by
reply views Thread by MichaelMortimer | last post: by
reply views Thread by CCCYYYY | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.