Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UPDATE error: "Argument data type text is invalid for argument 1 of REPLACE"

Tags:

sql-server

Why do I get this error from my query?

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

Query:

UPDATE 
    tableName
SET
    fieldName = REPLACE (fieldName, '&lt;', '<')
WHERE
    id = 100
like image 483
MufasaTheGreatAndPowerfull2 Avatar asked Jan 16 '15 11:01

MufasaTheGreatAndPowerfull2


2 Answers

Try this:

UPDATE tableName
SET fieldName = REPLACE (CONVERT(VARCHAR(MAX), fieldName), '&lt;', '<')
WHERE id = 100
like image 90
dario Avatar answered Oct 20 '22 14:10

dario


this will work for you

UPDATE yourTableName
SET 
fieldName = REPLACE (CONVERT(VARCHAR(MAX), fieldName), '&lt;', '<')
WHERE id = 100
like image 3
varsha Avatar answered Oct 20 '22 13:10

varsha