Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 problem with replace

Author  Topic 

lemondash
Posting Yak Master

159 Posts

Posted - 2004-06-15 : 04:39:21
I have a database which has a table called Documents and inside that table a colunm called sdescription. The problem is inside the sdescription field is data that i need to change.
In the past users have enter the letter E as an abbreviation for Euro, now i want to change all the E to the Euro symbol €. One more thing to note that all E have a numerical value straight after it.

Please help

Kristen
Test

22859 Posts

Posted - 2004-06-15 : 04:43:26
[code]
UPDATE Documents
SET sdescription = '€' + SUBSTRING(sdescription, 2, DATALENGTH(sdescription)-1)
WHERE sdescription LIKE 'E%' -- Use 'E[0-9]%' for ONLY E followed by digit
[/code]
Kristen
Go to Top of Page

lemondash
Posting Yak Master

159 Posts

Posted - 2004-06-15 : 05:03:18
Ah sorry forgot to mention that the E is not at the beginning of the field. This is an example of one of the strings in the sdescription field "DOLFIN NO.1 LTD: E300M CLASS A ASSET BACKED FLOATING RATE NOTES DUE 2004 AND E11M CLASS B ASSET BACKED FLOATING RATE NOTES DUE 2004 - OFFERING CIRCULAR"
Hope you can still help, many thanks.
Go to Top of Page

lemondash
Posting Yak Master

159 Posts

Posted - 2004-06-15 : 07:18:56
Thanks but that still dosen't work.
Go to Top of Page

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2004-06-15 : 08:02:31
Not elegant but should work...

UPDATE Documents
SET sdescription = Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(sdescription,' E0','€')' E1','€')' E2','€')' E3','€')' E4','€')' E5','€')' E6','€')' E7','€')' E8','€')' E9','€')
WHERE sdescription LIKE 'E%' -- Use 'E[0-9]%' for ONLY E followed by digit

Corey
Go to Top of Page
   

- Advertisement -