Reputation: 186
I am running below SQL commands and comparing results with calculator DEC to HEX output.
select CONVERT(VARBINARY(2),65280);
It gives me 0xFF00 which is right in Calculator. But when I execute below command:
select CONVERT(VARBINARY(6),894811944210);
It gives me 0x0C00000112B5 but when I check it on calculator the Result should be 0x00D056F2B512.
Is there anything I am doing incorrect?
Actually, I want to store the MAC Address in Table. for that I have created column with varbinary(250) datatype. So I am using below line in Insert Statement and while select command I am getting this output - 0x0C00000112B5
CONVERT(VARBINARY(6),894811944210)
Please suggest.
Upvotes: 1
Views: 1570
Reputation: 9947
MS Docs int, bigint, smallint, and tinyint (Transact-SQL)
Bigint Data type - 8 Bytes
SELECT CONVERT(VARBINARY(8),CAST(894811944210 AS BIGINT));
SELECT CAST(0x000000D056F2B512 AS BIGINT)
0x000000D056F2B512
894811944210
Upvotes: 4