As a result of a dumb code error, I have some hex strings (e.g. 0x8F276800EB0DA970) which were inserted in a varchar column but WITHOUT using single quotes. In other words, I incorrectly executed
Insert Into TableA (ColumnA) Values (0x8F276800EB0DA970)
instead of
Insert Into TableA (ColumnA) Values ('0x8F276800EB0DA970')
.
When I look at the actual content of ColumnA, it looks like jibberish (e.g. 'h ecpY3&*«<%).
There must be a way to read the content of ColumnA back to the original 0x8F276800EB0DA970 string but I haven't figured it out. I tried with Convert but it doesn't work.
Does anyone have a clue as to what to do? Thanks!
CodePudding user response:
convert it back to varbinary and then use convert with style 1 to convert back to varchar
convert(varchar(20), convert(varbinary(20), col), 1)