Reputation: 1319
create table hexvalue(Data varchar(10))
insert into hexvalue values('5'),('0E'),('12'),('17'),('15'),('EF'),('EF')
select convert(int, convert(varbinary, '0x'+Data, 1)) from hexvalue
This is throwing Error converting data type varchar to varbinary exception, except for '5'.
How can I fix this?
Upvotes: 0
Views: 4698
Reputation: 2287
Hex always have two characters. Try this
create table hexvalue(Data varchar(10))
insert into hexvalue values('05'),('0E'),('12'),('17'),('15'),('EF'),('EF')
select convert(int, convert(varbinary, '0x'+Data, 1)) from hexvalue
Upvotes: 2