Binary to Bigint Sample


  

 Declare @bStr varchar(16)='09EEDF7C10C41030'


  
 Select Convert(BIGINT,0x09EEDF7C10C41030) --715755114748710960

 --Use CONVERT function with style 2 to data type BIGINT

Select  Convert(bigint, CONVERT(VARBINARY(8),  @bStr,2))  

--check
Select   CONVERT(BINARY(8), CONVERT(BIGINT, 715755114748710960))  
--0x09EEDF7C10C41030

--Below returns wrong value
Select  Cast('0x'+@bStr as binary(8))  ---wrong



 

https://social.msdn.microsoft.com/Forums/sqlserver/en-US/ef5cd089-71c9-4ded-af69-8682d77595ed/hexadecimal-to-number-table-values-functionsp?forum=transactsql

http://stackoverflow.com/questions/33021992/i-want-to-get-hexadecimal-value-off-a-binary-value-removing-0x-from-it

Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s