user1751909
user1751909

Reputation: 229

decimal to hex conversion in sql server 2008

the hex value of 2716455883 is A1E9D3CB but using

SELECT CONVERT(VARBINARY(8), 2716455883) 

getting answer 0x0A000001CBD3E9A1

Upvotes: 2

Views: 6401

Answers (1)

RichardTheKiwi
RichardTheKiwi

Reputation: 107686

SELECT CONVERT(VARBINARY(8), cast(2716455883 as bigint))

It is due to the way SQL Server interprets literals without qualified types. Check this out

select sql_variant_property(2716455883, 'basetype'); -- numeric
select sql_variant_property(2716455883, 'precision'); -- 10
select sql_variant_property(2716455883, 'scale'); -- 0

Upvotes: 7

Related Questions