Unix Technical Forum

Problem with replace function

This is a discussion on Problem with replace function within the SQL Server forums, part of the Microsoft SQL Server category; --> Hi, Please find the below scenario Original Table course branch_exist BY 0 UI 1 PO 1 LI 0 MK ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-01-2008, 02:50 PM
meendar
 
Posts: n/a
Default 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!

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-01-2008, 02:50 PM
kb
 
Posts: n/a
Default Re: Problem with replace function

> 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/


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-01-2008, 02:50 PM
kb
 
Posts: n/a
Default Re: Problem with replace function

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/


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 03-01-2008, 02:50 PM
meendar
 
Posts: n/a
Default Re: Problem with replace function

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


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 07:16 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com