469,275 Members | 1,674 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Replace function

hi
I need to replace data on a field.
I know the function replace(coulmn_name,original_value,new_value)
But i want to replace more than one value - can it be done?

For example i have a field name Type. 'P' is Passport, 'V' is Visa.
I want to change 'P' to passport and 'V' to Visa.

thanks!
Aug 15 '07 #1
7 1909
Purple
404 Expert 256MB
Hi ronennoga and welcome to TSDN,

You could do this using T-SQL where you can use IF statements to test the fields value and conditionally set the change to value.

Take a look here for some more info..

Regards Purple
Aug 15 '07 #2
Hi ronennoga and welcome to TSDN,

You could do this using T-SQL where you can use IF statements to test the fields value and conditionally set the change to value.

Take a look here for some more info..

Regards Purple
hi Purple - thanks for your help
can u please give an example or a more specific link? i couldn't find it....

Many thanks
Noga
Aug 15 '07 #3
Purple
404 Expert 256MB
Hi Noga,

here is the link to the If... Else reference in the T-SQL reference.

Regards Purple
Aug 15 '07 #4
You could also use CASE to execute conditional logic (like IF and ELSE) inside a block statement.

For example:
Expand|Select|Wrap|Line Numbers
  1. Select Case [type] 
  2. When 'P' Then 'Passport'
  3. When 'V' Then 'Visa'
  4. Else [type]
  5. End as [aliasname]  --or orginal fieldname, this can be whatever you want.
  6.  
MSDN Reference (CASE)
Aug 15 '07 #5
Purple
404 Expert 256MB
Good suggestion bwestover,

especially valuable with more than a couple of conditions to be tested for..

Purple
Aug 15 '07 #6
worked like a charm...
thank u very much
Aug 16 '07 #7
Purple
404 Expert 256MB
ronennoga,

Very pleased to hear it.

Regards Purple
Aug 16 '07 #8

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by higabe | last post: by
12 posts views Thread by Brian | last post: by
5 posts views Thread by pembed2003 | last post: by
5 posts views Thread by djc | last post: by
10 posts views Thread by pamelafluente | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.