Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Convert string Hex to Numeric with inline TSQL Expand / Collapse
Author
Message
Posted Tuesday, November 8, 2011 8:04 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Yesterday @ 1:26 AM
Points: 33, Visits: 296
Comments posted to this topic are about the item Convert string Hex to Numeric with inline TSQL
Post #1202594
Posted Wednesday, August 8, 2012 8:11 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Yesterday @ 1:26 AM
Points: 33, Visits: 296
A faster way to convert Hex to Dec is
select CAST(CONVERT(VARBINARY, 'FF00FF', 2) AS INT)

The string to convert must be at least 2 chars long :

select CAST(CONVERT(VARBINARY, 'F', 2) AS INT) : error
select CAST(CONVERT(VARBINARY, '0F', 2) AS INT) : 15

Post #1341895
Posted Monday, December 17, 2012 7:08 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Yesterday @ 1:26 AM
Points: 33, Visits: 296
To convert fast from INT to HEX :
right(master.dbo.fn_varbintohexstr(cast( Disconnection_cause as INT) ),2)
Post #1397249
Posted Friday, January 18, 2013 4:09 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 12:53 AM
Points: 2,618, Visits: 2,466
Federico Iori (8/8/2012)
A faster way to convert Hex to Dec is
select CAST(CONVERT(VARBINARY, 'FF00FF', 2) AS INT)

The string to convert must be at least 2 chars long :

select CAST(CONVERT(VARBINARY, 'F', 2) AS INT) : error
select CAST(CONVERT(VARBINARY, '0F', 2) AS INT) : 15


the faster and faster:
select CONVERT(VARBINARY, 'fffe', 2)+0 --implicit cast
Post #1408809
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse