Showing posts with label branch. Show all posts
Showing posts with label branch. Show all posts

Friday, March 9, 2012

Problem with replace function

Hi,
Please find the below scenario
Original Table
course branch_exist
BY0
UI1
PO1
LI0
MK1
select REPLACE(branch_exist,1,'yes') as branch from university;
displays
course branch_exist
BY0
UIYes
POYes
LI0
MKYes
What i need is
course branch_exist
BYNo
UIYes
POYes
LINo
MKYes
Sql-Server replace function only accepts three arguments, any
suggestions will be greatly welcomed!
Hello,
Use CASE statement...
Thanks
Hari
"meendar" <askjavaprogrammers@.gmail.com> wrote in message
news:1176120159.024299.245830@.l77g2000hsb.googlegr oups.com...
> 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!
>

Problem with replace function

Hi,

Please find the below scenario

Original Table

course branch_exist
BY0
UI1
PO1
LI0
MK1

select REPLACE(branch_exist,1,'yes') as branch from university;

displays

course branch_exist
BY0
UIYes
POYes
LI0
MKYes

What i need is

course branch_exist
BYNo
UIYes
POYes
LINo
MKYes

Sql-Server replace function only accepts three arguments, any
suggestions will be greatly welcomed!What i need is:

Quote:

Originally Posted by

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/|||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/|||On Apr 9, 5:37 pm, "kb" <a...@.kbupdate.infowrote:

Quote:

Originally Posted by

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 !

Wednesday, March 7, 2012

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!Hello,
Use CASE statement...
Thanks
Hari
"meendar" <askjavaprogrammers@.gmail.com> wrote in message
news:1176120159.024299.245830@.l77g2000hsb.googlegroups.com...
> 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!
>