SELECT CONVERT(INT, REPLACE(UserID, CHAR(0), '')) FROM this fails: And the workaround I posted definitely works for me: DECLARE TABLE(UserID VARCHAR(32)) Ok, so that is definitely a 4-digit integer followed by six instances of CHAR(0). If you can't fix the data type immediately, then you can quickly find the culprit by adding a check constraint: ALTER TABLE dbo. Fix the data (and the data type while you're at it). In the meantime perhaps try: SELECT CONVERT(INT, REPLACE(UserID, CHAR(0), ''))īut that is not a long term solution. SET UserID = REPLACE(UserID, CHAR(0), '')īut then you'll also need to fix whatever is putting this bad data into the table in the first place. You could try updating the table to get rid of these characters: UPDATE dbo.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |