I have a table with Projects, in the description field I want to replace Char(10) with ” in a lot of records.
I can replace it record by record manually like this:
UPDATE tblProjects
SET Description = (SELECT Replace(Description, Char(10), ' ')
FROM tblProjects
WHERE ( Description LIKE '%' + Char(10) + '%' )
AND ProjectID = XAXD)
WHERE ( Description LIKE '%' + Char(10) + '%' )
AND ProjectID = XAXD
but would like a more generic solution like for foreach project and then have ProjectID as a variable.
Can’t you just do
You were repeating the condition in 2 places
You can also remove the
ANDpart to update all projects havingchar(10)or use parameter
@ProjectIDin place of ‘XAXD’