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
 General SQL Server Forums
 New to SQL Server Programming
 Replace Bad Characters

Author  Topic 

PeteLeHoq
Starting Member

37 Posts

Posted - 2013-12-10 : 11:00:04
I've got a lot of %20 characters in my tables, and need to remove them however I get the error:

Argument data type ntext is invalid for argument 1 of replace function.

My Code:

UPDATE cmsPropertyData
SET dataNtext = REPLACE(dataNtext,'%20','')
WHERE cmsPropertyData.contentNodeId = 1151

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2013-12-10 : 11:32:26
[code]UPDATE cmsPropertyData
SET dataNtext = REPLACE(convert(varchar(max), dataNtext),'%20','')
WHERE cmsPropertyData.contentNodeId = 1151
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-12-11 : 05:31:53
As a sidenote ntext datatype is deprecated from sql 2005 onwards. so you should be using nvarchar(max) instead

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -