--Find them
SELECT '('+FieldName+')'
FROM dbo.TableName
WHERE some condition exists
--Fix them (remove the whitespace)
UPDATE dbo.TableName
SET FieldName = LTRIM(RTRIM(FieldName))
WHERE some condition exists
If you've got a LOT of values with white space, you're definitely going to want to be careful with that update. Let me know if that's the case. Also, please understand that the above will only handle leading and trailing blank spaces. (LTRIM = leading, RTRIM = trailing) If you've got blank, or empty characters within the string values, you'll need to do something like this:
UPDATE dbo.TableName
SET FieldName = REPLACE(FieldName,' ','')
That will REPLACE any space in the targeted field with no space. Always smart to look at the before and after side by side, before performing the update:
SELECT FieldName, REPLACE(FieldName,' ','')
FROM dbo.TableName
No comments:
Post a Comment