November 4, 2009 at 2:27 am
Hello,
I got a question of replace. I got for example this string 'élève_à_6iéme - primàire' and i will transform it to 'ELEVE A 6IEME PRIMAIRE'.
Is there some defined function. Or must i use REPLACE multiple times.
It must work very fast because this are 5 fields in a database and i have around 4.000.000 records.
Thanks
johan
November 4, 2009 at 3:03 am
You didn’t specify the way that you want to modify the data. In your example you changed letters to different letters and not only made those capital letters (for example, the letters é, è and e were all modified to E). If this was done by mistake and you want to presserve the original letters, but just make them capital letters, then you can do it with the upper function. If on the other hand you want all the letters to be capital English letters, you’ll need to try and find a collation that can do that. The cod bellow showes how to do it, but if you’ll select the third way (modifying the collation), you should learn more about the collation that you choos to make sure that it won’t damage your data
select 'élève_à_6iéme' as OriginalString,
replace(upper('élève_à_6iéme'),'_',' ') as JustUpper,
replace(upper('élève_à_6iéme'),'_',' ') collate SQL_MixDiction_CP1253_CS_AS as UpperAndNewCollation
Adi
--------------------------------------------------------------
To know how to ask questions and increase the chances of getting asnwers:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply