sql server - Error converting data type varchar to varbinary in sql only for few values -


if(isnumeric(rtrim(ltrim('83b1b88'))) = 0) select convert(varchar, convert(int, convert(varbinary, convert(varchar, '0x' + '83b1b88'), 1))) 

i not sure why sql throwing error converting data type varchar varbinary getting exception values 1b91b32,169df90, 13077b5

can me out ?

you're passing style of 1 convert.

if data_type binary type, expression must character expression. expression must composed of number of hexadecimal digits (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f, a, b, c, d, e, f). if style set 1 characters 0x must first 2 characters in expression. if expression contains odd number of characters or if of characters invalid error raised.

my emphasis.

all of examples of invalid sequences appear have odd lengths. should add padding 0 if have odd length sequence. whether pad @ start or end depends on exact requirements, sequence came from, etc.


Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

Ruby Google Calendar Integration Watch Event / Push Notification -