I have a column in a database (SQL Server 2005) that has data with "\ 0" at the end. When querying in SQL Server, this character is not displayed and does not seem to exist. When I look at my C # code, there is a symbol there. This symbol causes an error on our website, and we need it to be removed from all affected lines.
Is there an SQL query that I can write to easily remove this character from all affected records? I can get all the affected records, but I have no way to update the record to a new value (without "\ 0").
UPDATE: This seems to work:
Select * from TABLE where UNICODE(SUBSTRING(naughtyField, LEN(naughtyField), 1)) = 0
So:
Update TABLE SET naughtyField = SUBSTRING(naughtyField, 1, LEN(naughtyField) - 1) where UNICODE(SUBSTRING(naughtyField, LEN(naughtyField), 1)) = 0
sql database sql-server sql-server-2005
Martin
source share