Forum Moderators: open

Message Too Old, No Replies

Running a SQL query to replace certain characters in a table

         

midoriweb

2:02 am on Jan 12, 2007 (gmt 0)

10+ Year Member



Is this possible? We have a database that contains many characters and symbols we no longer want (or that we need to replace with something else). For example... We some records in a database that contain the copyright symbol:

©

And we want to replace that with:

©

Is this possible? If so... can someone guide me in the right direction? :)

Our table is titled Product_Descriptions and the column we want to run this query on is ProductDescription.

midoriweb

2:08 am on Jan 12, 2007 (gmt 0)

10+ Year Member



Oops... forgot to add something.

I've already searched and I found this:

UPDATE <table>
SET name = REPLACE(LTRIM(RTRIM(name)), '©', '&copy;')

That should work right? But what do I enter to run this on my specific table/column?

midoriweb

2:19 am on Jan 12, 2007 (gmt 0)

10+ Year Member



Sorry... I should have clarified... this on on MS SQL.

phranque

2:19 am on Jan 12, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



UPDATE Product_Descriptions
SET ProductDescription = REPLACE(LTRIM(RTRIM(ProductDescription)), '©', '&copy;');

phranque

2:32 am on Jan 12, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



maybe ms sql doesn't need the trailing ';'

midoriweb

6:58 am on Jan 12, 2007 (gmt 0)

10+ Year Member



Thanks for the help :)

So I ran the following:

UPDATE Products_Descriptions
SET ProductDescription = REPLACE(LTRIM(RTRIM(ProductDescription)), '©', '&copy;')

But it returned this message:

Server: Msg 8116, Level 16, State 2, Line 1
Argument data type text is invalid for argument 1 of rtrim function.

Any ideas?

midoriweb

7:05 am on Jan 12, 2007 (gmt 0)

10+ Year Member



I tried:

UPDATE Products_Descriptions
SET ProductDescription = REPLACE(ProductDescription,'©','&copy;')

But got this error:

Server: Msg 8116, Level 16, State 1, Line 1
Argument data type text is invalid for argument 1 of replace function.

midoriweb

7:49 am on Jan 12, 2007 (gmt 0)

10+ Year Member



I've done some more research and it appears since the database column is of type TEXT I can't run the replace function.

So... next best thing is to write a custom ASP Script. This isn't the right forum for this so I created a new thread here:

[webmasterworld.com...]

If anyone can help me I'd really appreciate it :)