GeekInterview.com
Series: Subject: Topic:
Question: 192 of 198

What is the difference between "translate" and "replace"?

Asked by: Beena | Member Since Sep-2005 | Asked on: Sep 19th, 2005

View all questions by Beena   View all answers by Beena

Editorial / Best Answer

Answered by: jayaprakash.raman

View all answers by jayaprakash.raman

Member Since Apr-2007 | Answered On : Apr 24th, 2007

Please refer that here we are discussing about Sql Server only. There is no function named 'Translate' in Sql Server. 'Translate' function exists in Oracle for translating a single character to some other character.

Replace fucntion in Sql server is used to replace a string as well as character to another string or character. No need to have a seperate function like Transalate in Oracle:

Find below the examples to get the clear idea:

Ex 1: Sql Server replace function similar to Oracle Replace function

Declare @Str varchar(100)

set @Str='India is my country'

print @Str

print replace(@Str,'India','Pakistan')



Result

India is my country

Pakistan is my country


Ex 1: Sql Server replace function similar to Oracle Translate Replace function

Declare @Str varchar(100)

set @Str='Think You'

print @Str

print replace(@Str,'i','a')
Result

Think You

Thank You



Note: Please try to post Sql server questions only here. Ther is a seperate section available for Oracle. If we mix both, it will confuse the people who are specializing their skill in particular area. Thank you.

Showing Answers 1 - 3 of 3 Answers
rahultripathi

Answered On : Sep 21st, 2005

View all answers by rahultripathi

Replace replace every instence of character with character sting by the given charator of string. this work for entire word and pattern,. Translate replace the one charecte  at a time.Translating the nth character match with the nth character with the replacemnt string .

  
Login to rate this answer.
aruna

Answered On : Apr 3rd, 2006

Translate is a character wise functionwhere as replace is a string wise

Yes  1 User has rated as useful.
  
Login to rate this answer.

Please refer that here we are discussing about Sql Server only. There is no function named 'Translate' in Sql Server. 'Translate' function exists in Oracle for translating a single character to some other character.Replace fucntion in Sql server is used to replace a string as well as character to another string or character. No need to have a seperate function like Transalate in Oracle:Find below the examples to get the clear idea:Ex 1: Sql Server replace function similar to Oracle Replace functionDeclare @Str varchar(100)set @Str='India is my country'print @Strprint replace(@Str,'India','Pakistan')ResultIndia is my countryPakistan is my countryEx 1: Sql Server replace function similar to Oracle Translate Replace functionDeclare @Str varchar(100)set @Str='Think You'print @Strprint replace(@Str,'i','a')ResultThink YouThank YouNote: Please try to post Sql server questions only here. Ther is a seperate section available for Oracle. If we mix both, it will confuse the people who are specializing their skill in particular area. Thank you.

Yes  3 Users have rated as useful.
  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.