<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: SQL SERVER &#8211; Question &#8211; How to Convert Hex to Decimal</title>
	<atom:link href="http://blog.sqlauthority.com/2010/02/01/sql-server-question-how-to-convert-hex-to-decimal/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2010/02/01/sql-server-question-how-to-convert-hex-to-decimal/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Fri, 17 May 2013 15:26:57 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Jayesh Gangrade</title>
		<link>http://blog.sqlauthority.com/2010/02/01/sql-server-question-how-to-convert-hex-to-decimal/#comment-359127</link>
		<dc:creator><![CDATA[Jayesh Gangrade]]></dc:creator>
		<pubDate>Fri, 12 Oct 2012 10:11:20 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7785#comment-359127</guid>
		<description><![CDATA[Hi pinal,

please give me solution of following error

The TCP/IP connection to the host 11.01.0.45, port 1433 has failed. Error: &quot;Address already in use: connect. Verify the connection properties, check that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port, and that no firewall is blocking TCP connections to the port.&quot;.
1000
com.websym.common.exception.DBException: org.hibernate.exception.JDBCConnectionException: Cannot open connection


Jayesh G]]></description>
		<content:encoded><![CDATA[<p>Hi pinal,</p>
<p>please give me solution of following error</p>
<p>The TCP/IP connection to the host 11.01.0.45, port 1433 has failed. Error: &#8220;Address already in use: connect. Verify the connection properties, check that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port, and that no firewall is blocking TCP connections to the port.&#8221;.<br />
1000<br />
com.websym.common.exception.DBException: org.hibernate.exception.JDBCConnectionException: Cannot open connection</p>
<p>Jayesh G</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vinay Pandey</title>
		<link>http://blog.sqlauthority.com/2010/02/01/sql-server-question-how-to-convert-hex-to-decimal/#comment-357896</link>
		<dc:creator><![CDATA[Vinay Pandey]]></dc:creator>
		<pubDate>Tue, 09 Oct 2012 13:13:56 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7785#comment-357896</guid>
		<description><![CDATA[CREATE TABLE #t
(
ip varchar(200)
)

insert into #t
select &#039;C0A8019A&#039;
union all
select &#039;0A0B0028&#039;
union all
select &#039;0A0B2531&#039;
union all
select &#039;0A0B62CF&#039;
union all
select &#039;0A0B415F&#039;
union all
select &#039;0A0B62CF&#039;
union all
select &#039;0A0B2531&#039;
union all
select &#039;0A0B62CF&#039;
union all
select &#039;0A0B2531&#039;
union all
select &#039;0A0B62CF&#039;
union all
select &#039;0A0B415F&#039;
union all
select &#039;0A0B81B0&#039;


select ip,substring(ip,1,2) A1
,substring(ip,len(substring(ip,1,2))+1,2) B1
,substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2) C1
,substring(ip,len(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2))+5,2) D1

,case	when left(substring(ip,1,2),1) =&#039;A&#039; Then 10 * 16
		when left(substring(ip,1,2),1) =&#039;B&#039; Then 11 * 16
		when left(substring(ip,1,2),1) =&#039;C&#039; Then 12 * 16
		when left(substring(ip,1,2),1) =&#039;D&#039; Then 13 * 16
		when left(substring(ip,1,2),1) =&#039;E&#039; Then 14 * 16
		when left(substring(ip,1,2),1) =&#039;F&#039; Then 15 * 16
ELSE	left(substring(ip,1,2),1) * 16	
		END
		+ 
case	when Right(substring(ip,1,2),1) =&#039;A&#039; Then 10 
		when Right(substring(ip,1,2),1) =&#039;B&#039; Then 11 
		when Right(substring(ip,1,2),1) =&#039;C&#039; Then 12 
		when Right(substring(ip,1,2),1) =&#039;D&#039; Then 13 
		when Right(substring(ip,1,2),1) =&#039;E&#039; Then 14 
		when Right(substring(ip,1,2),1) =&#039;F&#039; Then 15 
ELSE	Right(substring(ip,1,2),1)	
		END AS A
		
,case	when left(substring(ip,len(substring(ip,1,2))+1,2),1) =&#039;A&#039; Then 10 * 16
		when left(substring(ip,len(substring(ip,1,2))+1,2),1) =&#039;B&#039; Then 11 * 16
		when left(substring(ip,len(substring(ip,1,2))+1,2),1) =&#039;C&#039; Then 12 * 16
		when left(substring(ip,len(substring(ip,1,2))+1,2),1) =&#039;D&#039; Then 13 * 16
		when left(substring(ip,len(substring(ip,1,2))+1,2),1) =&#039;E&#039; Then 14 * 16
		when left(substring(ip,len(substring(ip,1,2))+1,2),1) =&#039;F&#039; Then 15 * 16
ELSE	left(substring(ip,len(substring(ip,1,2))+1,2),1) * 16	
		END
		+ 
case	when Right(substring(ip,len(substring(ip,1,2))+1,2),1) =&#039;A&#039; Then 10 
		when Right(substring(ip,len(substring(ip,1,2))+1,2),1) =&#039;B&#039; Then 11 
		when Right(substring(ip,len(substring(ip,1,2))+1,2),1) =&#039;C&#039; Then 12 
		when Right(substring(ip,len(substring(ip,1,2))+1,2),1) =&#039;D&#039; Then 13 
		when Right(substring(ip,len(substring(ip,1,2))+1,2),1) =&#039;E&#039; Then 14 
		when Right(substring(ip,len(substring(ip,1,2))+1,2),1) =&#039;F&#039; Then 15 
ELSE	Right(substring(ip,len(substring(ip,1,2))+1,2),1)	
		END AS B

,case	when left(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2),1) =&#039;A&#039; Then 10 * 16
		when left(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2),1) =&#039;B&#039; Then 11 * 16
		when left(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2),1) =&#039;C&#039; Then 12 * 16
		when left(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2),1) =&#039;D&#039; Then 13 * 16
		when left(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2),1) =&#039;E&#039; Then 14 * 16
		when left(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2),1) =&#039;F&#039; Then 15 * 16
ELSE	left(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2),1)	 * 16
		END
		+ 
case	when Right(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2),1) =&#039;A&#039; Then 10 
		when Right(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2),1) =&#039;B&#039; Then 11 
		when Right(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2),1) =&#039;C&#039; Then 12 
		when Right(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2),1) =&#039;D&#039; Then 13 
		when Right(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2),1) =&#039;E&#039; Then 14 
		when Right(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2),1) =&#039;F&#039; Then 15 
ELSE	Right(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2),1)	
		END AS C
		
,case	when left(substring(ip,len(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2))+5,2),1) =&#039;A&#039; Then 10 * 16
		when left(substring(ip,len(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2))+5,2),1) =&#039;B&#039; Then 11 * 16
		when left(substring(ip,len(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2))+5,2),1) =&#039;C&#039; Then 12 * 16
		when left(substring(ip,len(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2))+5,2),1) =&#039;D&#039; Then 13 * 16
		when left(substring(ip,len(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2))+5,2),1) =&#039;E&#039; Then 14 * 16
		when left(substring(ip,len(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2))+5,2),1) =&#039;F&#039; Then 15 * 16
ELSE	left(substring(ip,len(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2))+5,2),1)	* 16
		END
		+ 
case	when Right(substring(ip,len(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2))+5,2),1) =&#039;A&#039; Then 10 
		when Right(substring(ip,len(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2))+5,2),1) =&#039;B&#039; Then 11 
		when Right(substring(ip,len(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2))+5,2),1) =&#039;C&#039; Then 12 
		when Right(substring(ip,len(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2))+5,2),1) =&#039;D&#039; Then 13 
		when Right(substring(ip,len(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2))+5,2),1) =&#039;E&#039; Then 14 
		when Right(substring(ip,len(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2))+5,2),1) =&#039;F&#039; Then 15 
ELSE	Right(substring(ip,len(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2))+5,2),1)	
		END AS D
INTO #temp	
from #t

select ip, convert(varchar,A)+&#039;.&#039;+ convert(varchar,B)+&#039;.&#039;+convert(varchar,C) +&#039;.&#039;+convert(varchar,D) IPAddress from #temp]]></description>
		<content:encoded><![CDATA[<p>CREATE TABLE #t<br />
(<br />
ip varchar(200)<br />
)</p>
<p>insert into #t<br />
select &#8216;C0A8019A&#8217;<br />
union all<br />
select &#8217;0A0B0028&#8242;<br />
union all<br />
select &#8217;0A0B2531&#8242;<br />
union all<br />
select &#8217;0A0B62CF&#8217;<br />
union all<br />
select &#8217;0A0B415F&#8217;<br />
union all<br />
select &#8217;0A0B62CF&#8217;<br />
union all<br />
select &#8217;0A0B2531&#8242;<br />
union all<br />
select &#8217;0A0B62CF&#8217;<br />
union all<br />
select &#8217;0A0B2531&#8242;<br />
union all<br />
select &#8217;0A0B62CF&#8217;<br />
union all<br />
select &#8217;0A0B415F&#8217;<br />
union all<br />
select &#8217;0A0B81B0&#8242;</p>
<p>select ip,substring(ip,1,2) A1<br />
,substring(ip,len(substring(ip,1,2))+1,2) B1<br />
,substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2) C1<br />
,substring(ip,len(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2))+5,2) D1</p>
<p>,case	when left(substring(ip,1,2),1) =&#8217;A&#8217; Then 10 * 16<br />
		when left(substring(ip,1,2),1) =&#8217;B&#8217; Then 11 * 16<br />
		when left(substring(ip,1,2),1) =&#8217;C&#8217; Then 12 * 16<br />
		when left(substring(ip,1,2),1) =&#8217;D&#8217; Then 13 * 16<br />
		when left(substring(ip,1,2),1) =&#8217;E&#8217; Then 14 * 16<br />
		when left(substring(ip,1,2),1) =&#8217;F&#8217; Then 15 * 16<br />
ELSE	left(substring(ip,1,2),1) * 16<br />
		END<br />
		+<br />
case	when Right(substring(ip,1,2),1) =&#8217;A&#8217; Then 10<br />
		when Right(substring(ip,1,2),1) =&#8217;B&#8217; Then 11<br />
		when Right(substring(ip,1,2),1) =&#8217;C&#8217; Then 12<br />
		when Right(substring(ip,1,2),1) =&#8217;D&#8217; Then 13<br />
		when Right(substring(ip,1,2),1) =&#8217;E&#8217; Then 14<br />
		when Right(substring(ip,1,2),1) =&#8217;F&#8217; Then 15<br />
ELSE	Right(substring(ip,1,2),1)<br />
		END AS A</p>
<p>,case	when left(substring(ip,len(substring(ip,1,2))+1,2),1) =&#8217;A&#8217; Then 10 * 16<br />
		when left(substring(ip,len(substring(ip,1,2))+1,2),1) =&#8217;B&#8217; Then 11 * 16<br />
		when left(substring(ip,len(substring(ip,1,2))+1,2),1) =&#8217;C&#8217; Then 12 * 16<br />
		when left(substring(ip,len(substring(ip,1,2))+1,2),1) =&#8217;D&#8217; Then 13 * 16<br />
		when left(substring(ip,len(substring(ip,1,2))+1,2),1) =&#8217;E&#8217; Then 14 * 16<br />
		when left(substring(ip,len(substring(ip,1,2))+1,2),1) =&#8217;F&#8217; Then 15 * 16<br />
ELSE	left(substring(ip,len(substring(ip,1,2))+1,2),1) * 16<br />
		END<br />
		+<br />
case	when Right(substring(ip,len(substring(ip,1,2))+1,2),1) =&#8217;A&#8217; Then 10<br />
		when Right(substring(ip,len(substring(ip,1,2))+1,2),1) =&#8217;B&#8217; Then 11<br />
		when Right(substring(ip,len(substring(ip,1,2))+1,2),1) =&#8217;C&#8217; Then 12<br />
		when Right(substring(ip,len(substring(ip,1,2))+1,2),1) =&#8217;D&#8217; Then 13<br />
		when Right(substring(ip,len(substring(ip,1,2))+1,2),1) =&#8217;E&#8217; Then 14<br />
		when Right(substring(ip,len(substring(ip,1,2))+1,2),1) =&#8217;F&#8217; Then 15<br />
ELSE	Right(substring(ip,len(substring(ip,1,2))+1,2),1)<br />
		END AS B</p>
<p>,case	when left(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2),1) =&#8217;A&#8217; Then 10 * 16<br />
		when left(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2),1) =&#8217;B&#8217; Then 11 * 16<br />
		when left(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2),1) =&#8217;C&#8217; Then 12 * 16<br />
		when left(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2),1) =&#8217;D&#8217; Then 13 * 16<br />
		when left(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2),1) =&#8217;E&#8217; Then 14 * 16<br />
		when left(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2),1) =&#8217;F&#8217; Then 15 * 16<br />
ELSE	left(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2),1)	 * 16<br />
		END<br />
		+<br />
case	when Right(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2),1) =&#8217;A&#8217; Then 10<br />
		when Right(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2),1) =&#8217;B&#8217; Then 11<br />
		when Right(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2),1) =&#8217;C&#8217; Then 12<br />
		when Right(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2),1) =&#8217;D&#8217; Then 13<br />
		when Right(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2),1) =&#8217;E&#8217; Then 14<br />
		when Right(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2),1) =&#8217;F&#8217; Then 15<br />
ELSE	Right(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2),1)<br />
		END AS C</p>
<p>,case	when left(substring(ip,len(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2))+5,2),1) =&#8217;A&#8217; Then 10 * 16<br />
		when left(substring(ip,len(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2))+5,2),1) =&#8217;B&#8217; Then 11 * 16<br />
		when left(substring(ip,len(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2))+5,2),1) =&#8217;C&#8217; Then 12 * 16<br />
		when left(substring(ip,len(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2))+5,2),1) =&#8217;D&#8217; Then 13 * 16<br />
		when left(substring(ip,len(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2))+5,2),1) =&#8217;E&#8217; Then 14 * 16<br />
		when left(substring(ip,len(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2))+5,2),1) =&#8217;F&#8217; Then 15 * 16<br />
ELSE	left(substring(ip,len(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2))+5,2),1)	* 16<br />
		END<br />
		+<br />
case	when Right(substring(ip,len(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2))+5,2),1) =&#8217;A&#8217; Then 10<br />
		when Right(substring(ip,len(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2))+5,2),1) =&#8217;B&#8217; Then 11<br />
		when Right(substring(ip,len(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2))+5,2),1) =&#8217;C&#8217; Then 12<br />
		when Right(substring(ip,len(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2))+5,2),1) =&#8217;D&#8217; Then 13<br />
		when Right(substring(ip,len(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2))+5,2),1) =&#8217;E&#8217; Then 14<br />
		when Right(substring(ip,len(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2))+5,2),1) =&#8217;F&#8217; Then 15<br />
ELSE	Right(substring(ip,len(substring(ip,len(substring(ip,len(substring(ip,1,2))+1,2))+3,2))+5,2),1)<br />
		END AS D<br />
INTO #temp<br />
from #t</p>
<p>select ip, convert(varchar,A)+&#8217;.'+ convert(varchar,B)+&#8217;.'+convert(varchar,C) +&#8217;.'+convert(varchar,D) IPAddress from #temp</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER &#8211; Answer &#8211; How to Convert Hex to Decimal or INT &#171; SQL Server Journey with SQL Authority</title>
		<link>http://blog.sqlauthority.com/2010/02/01/sql-server-question-how-to-convert-hex-to-decimal/#comment-319077</link>
		<dc:creator><![CDATA[SQL SERVER &#8211; Answer &#8211; How to Convert Hex to Decimal or INT &#171; SQL Server Journey with SQL Authority]]></dc:creator>
		<pubDate>Thu, 26 Jul 2012 01:30:46 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7785#comment-319077</guid>
		<description><![CDATA[[...] Has it ever happened to you that you say something but forget to follow up due to any reason? It usually does not happen to me as I try to remember everything in my task list but there is always an exception. Last year I asked a question regarding about how to convert Hex to Decimal. I promised that I will post an answer with Due Credit to the author but never got around to post a blog post around it. Read the original post over here SQL SERVER – Question – How to Convert Hex to Decimal. [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Has it ever happened to you that you say something but forget to follow up due to any reason? It usually does not happen to me as I try to remember everything in my task list but there is always an exception. Last year I asked a question regarding about how to convert Hex to Decimal. I promised that I will post an answer with Due Credit to the author but never got around to post a blog post around it. Read the original post over here SQL SERVER – Question – How to Convert Hex to Decimal. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kevin yen</title>
		<link>http://blog.sqlauthority.com/2010/02/01/sql-server-question-how-to-convert-hex-to-decimal/#comment-284466</link>
		<dc:creator><![CDATA[kevin yen]]></dc:creator>
		<pubDate>Mon, 14 May 2012 08:17:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7785#comment-284466</guid>
		<description><![CDATA[today your website posts have helped me lots of times to resolve problem from my manager.
you&#039;re the best!!
thank you]]></description>
		<content:encoded><![CDATA[<p>today your website posts have helped me lots of times to resolve problem from my manager.<br />
you&#8217;re the best!!<br />
thank you</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SPV</title>
		<link>http://blog.sqlauthority.com/2010/02/01/sql-server-question-how-to-convert-hex-to-decimal/#comment-272250</link>
		<dc:creator><![CDATA[SPV]]></dc:creator>
		<pubDate>Thu, 05 Apr 2012 04:37:10 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7785#comment-272250</guid>
		<description><![CDATA[Here is another solution

SELECT CONVERT(int, CONVERT(varbinary, &#039;0xFF&#039;, 1))  returns 255

so replace &#039;0xFF&#039; with any other hex value and try. Remember to always include &#039;0x&#039; in the beginning.]]></description>
		<content:encoded><![CDATA[<p>Here is another solution</p>
<p>SELECT CONVERT(int, CONVERT(varbinary, &#8217;0xFF&#8217;, 1))  returns 255</p>
<p>so replace &#8217;0xFF&#8217; with any other hex value and try. Remember to always include &#8217;0x&#8217; in the beginning.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: aspdotnetcsharpsntosh</title>
		<link>http://blog.sqlauthority.com/2010/02/01/sql-server-question-how-to-convert-hex-to-decimal/#comment-261106</link>
		<dc:creator><![CDATA[aspdotnetcsharpsntosh]]></dc:creator>
		<pubDate>Fri, 09 Mar 2012 13:56:09 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7785#comment-261106</guid>
		<description><![CDATA[hi. 
i want to convert hex to readable string how to do pls help me its very urgent.

i have hex like &quot;0605040B8423F0660601AE02056A00&quot;
want to convert in human readable string.

pls help .....]]></description>
		<content:encoded><![CDATA[<p>hi.<br />
i want to convert hex to readable string how to do pls help me its very urgent.</p>
<p>i have hex like &#8220;0605040B8423F0660601AE02056A00&#8243;<br />
want to convert in human readable string.</p>
<p>pls help &#8230;..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: knightEknight</title>
		<link>http://blog.sqlauthority.com/2010/02/01/sql-server-question-how-to-convert-hex-to-decimal/#comment-183799</link>
		<dc:creator><![CDATA[knightEknight]]></dc:creator>
		<pubDate>Wed, 26 Oct 2011 19:15:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7785#comment-183799</guid>
		<description><![CDATA[Moderator, please remove the &quot;commented&quot; values after the declare statement above.  The two comment dashes got replaced by another symbol.  Thanks]]></description>
		<content:encoded><![CDATA[<p>Moderator, please remove the &#8220;commented&#8221; values after the declare statement above.  The two comment dashes got replaced by another symbol.  Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: knightEknight</title>
		<link>http://blog.sqlauthority.com/2010/02/01/sql-server-question-how-to-convert-hex-to-decimal/#comment-183798</link>
		<dc:creator><![CDATA[knightEknight]]></dc:creator>
		<pubDate>Wed, 26 Oct 2011 19:13:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7785#comment-183798</guid>
		<description><![CDATA[building on Ray&#039;s contribution above, here is the generic case:

declare @hex varchar(64) = &#039;0x00FF&#039; 
select cast( CONVERT(VARBINARY,&#039;0x&#039;+right(&#039;00000000&#039;+replace(@hex,&#039;x&#039;,&#039;&#039;),8),1) as int)

This could easily be made into a function.]]></description>
		<content:encoded><![CDATA[<p>building on Ray&#8217;s contribution above, here is the generic case:</p>
<p>declare @hex varchar(64) = &#8217;0x00FF&#8217;<br />
select cast( CONVERT(VARBINARY,&#8217;0x&#8217;+right(&#8217;00000000&#8242;+replace(@hex,&#8217;x',&#8221;),8),1) as int)</p>
<p>This could easily be made into a function.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ray</title>
		<link>http://blog.sqlauthority.com/2010/02/01/sql-server-question-how-to-convert-hex-to-decimal/#comment-172600</link>
		<dc:creator><![CDATA[Ray]]></dc:creator>
		<pubDate>Tue, 27 Sep 2011 20:34:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7785#comment-172600</guid>
		<description><![CDATA[A Little late to the party, however when reading books online for convert I noticed you could apply styles when converting to binary.

SELECT CONVERT(VARBINARY(8), 65535),CAST(0x0000FFFF AS INT), 
	-- If the value is a string without the 0x
	CAST(CONVERT(VARBINARY, &#039;ffff&#039;, 2) AS INT),
	CAST(CONVERT(VARBINARY, &#039;0000ffff&#039;, 2) AS INT),
	-- or if your string has the 0x
	CAST(CONVERT(VARBINARY, &#039;0x0000FFFF&#039;, 1) AS INT),
	CAST(CONVERT(VARBINARY, &#039;0xFFFF&#039;, 1) AS INT)

0x0000FFFF,65535,65535,65535,65535,65535]]></description>
		<content:encoded><![CDATA[<p>A Little late to the party, however when reading books online for convert I noticed you could apply styles when converting to binary.</p>
<p>SELECT CONVERT(VARBINARY(8), 65535),CAST(0x0000FFFF AS INT),<br />
	&#8211; If the value is a string without the 0x<br />
	CAST(CONVERT(VARBINARY, &#8216;ffff&#8217;, 2) AS INT),<br />
	CAST(CONVERT(VARBINARY, &#8217;0000ffff&#8217;, 2) AS INT),<br />
	&#8211; or if your string has the 0x<br />
	CAST(CONVERT(VARBINARY, &#8217;0x0000FFFF&#8217;, 1) AS INT),<br />
	CAST(CONVERT(VARBINARY, &#8217;0xFFFF&#8217;, 1) AS INT)</p>
<p>0x0000FFFF,65535,65535,65535,65535,65535</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Biju.K.S</title>
		<link>http://blog.sqlauthority.com/2010/02/01/sql-server-question-how-to-convert-hex-to-decimal/#comment-84289</link>
		<dc:creator><![CDATA[Biju.K.S]]></dc:creator>
		<pubDate>Mon, 16 Aug 2010 12:05:08 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7785#comment-84289</guid>
		<description><![CDATA[Hi,

please run this,

select convert(varbinary(2),unicode(N’B&#039;))
go
declare @tmp_var varchar(10)
SET @tmp_var = sys.fn_varbintohexstr(convert(varbinary(2),unicode(N’B&#039;)))
select @tmp_var ‘tmp_var’

;)

Thanks,
Biju]]></description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>please run this,</p>
<p>select convert(varbinary(2),unicode(N’B&#8217;))<br />
go<br />
declare @tmp_var varchar(10)<br />
SET @tmp_var = sys.fn_varbintohexstr(convert(varbinary(2),unicode(N’B&#8217;)))<br />
select @tmp_var ‘tmp_var’</p>
<p>;)</p>
<p>Thanks,<br />
Biju</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Biju.K.S</title>
		<link>http://blog.sqlauthority.com/2010/02/01/sql-server-question-how-to-convert-hex-to-decimal/#comment-84288</link>
		<dc:creator><![CDATA[Biju.K.S]]></dc:creator>
		<pubDate>Mon, 16 Aug 2010 12:04:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7785#comment-84288</guid>
		<description><![CDATA[Hi,

please run this,

select convert(varbinary(2),unicode(N&#039;B&#039;))
go
declare @tmp_var varchar(10)
SET @tmp_var = sys.fn_varbintohexstr(convert(varbinary(2),unicode(N&#039;B&#039;)))
select @tmp_var &#039;tmp_var&#039;

;)

Thanks,
Biju]]></description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>please run this,</p>
<p>select convert(varbinary(2),unicode(N&#8217;B'))<br />
go<br />
declare @tmp_var varchar(10)<br />
SET @tmp_var = sys.fn_varbintohexstr(convert(varbinary(2),unicode(N&#8217;B')))<br />
select @tmp_var &#8216;tmp_var&#8217;</p>
<p>;)</p>
<p>Thanks,<br />
Biju</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Biju.K.S</title>
		<link>http://blog.sqlauthority.com/2010/02/01/sql-server-question-how-to-convert-hex-to-decimal/#comment-84279</link>
		<dc:creator><![CDATA[Biju.K.S]]></dc:creator>
		<pubDate>Mon, 16 Aug 2010 11:39:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7785#comment-84279</guid>
		<description><![CDATA[No practical use..!
I just want to know that...

Thanks for your reply..:)]]></description>
		<content:encoded><![CDATA[<p>No practical use..!<br />
I just want to know that&#8230;</p>
<p>Thanks for your reply..:)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Madhivanan</title>
		<link>http://blog.sqlauthority.com/2010/02/01/sql-server-question-how-to-convert-hex-to-decimal/#comment-83974</link>
		<dc:creator><![CDATA[Madhivanan]]></dc:creator>
		<pubDate>Fri, 13 Aug 2010 13:06:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7785#comment-83974</guid>
		<description><![CDATA[You can&#039;t do that. Why do you want to do that?]]></description>
		<content:encoded><![CDATA[<p>You can&#8217;t do that. Why do you want to do that?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Biju.K.S</title>
		<link>http://blog.sqlauthority.com/2010/02/01/sql-server-question-how-to-convert-hex-to-decimal/#comment-83963</link>
		<dc:creator><![CDATA[Biju.K.S]]></dc:creator>
		<pubDate>Fri, 13 Aug 2010 11:25:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7785#comment-83963</guid>
		<description><![CDATA[Hi All,

Please answer this,

select convert(varbinary(2),unicode(N&#039;B&#039;))
go
declare @tmp_var varchar(10)
SET @tmp_var = convert(varbinary(2),unicode(N&#039;B&#039;))
select @tmp_var &#039;tmp_var&#039;

Execute this query....

When a varbinary value is assigned to a varchar type, then it shows NULL.  Why???

By
Biju.K.S]]></description>
		<content:encoded><![CDATA[<p>Hi All,</p>
<p>Please answer this,</p>
<p>select convert(varbinary(2),unicode(N&#8217;B'))<br />
go<br />
declare @tmp_var varchar(10)<br />
SET @tmp_var = convert(varbinary(2),unicode(N&#8217;B'))<br />
select @tmp_var &#8216;tmp_var&#8217;</p>
<p>Execute this query&#8230;.</p>
<p>When a varbinary value is assigned to a varchar type, then it shows NULL.  Why???</p>
<p>By<br />
Biju.K.S</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David</title>
		<link>http://blog.sqlauthority.com/2010/02/01/sql-server-question-how-to-convert-hex-to-decimal/#comment-65086</link>
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Tue, 13 Apr 2010 09:08:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7785#comment-65086</guid>
		<description><![CDATA[Hi guys,
Here&#039;s an online tool I use to convert hex to decimal: &lt;a href=&quot;http://www.stringfunction.com/hex-decimal.html&quot; rel=&quot;nofollow&quot;&gt;hex to decimal converter&lt;/a&gt;
Pretty cool!
David]]></description>
		<content:encoded><![CDATA[<p>Hi guys,<br />
Here&#8217;s an online tool I use to convert hex to decimal: <a href="http://www.stringfunction.com/hex-decimal.html" rel="nofollow">hex to decimal converter</a><br />
Pretty cool!<br />
David</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vedran Kesegic</title>
		<link>http://blog.sqlauthority.com/2010/02/01/sql-server-question-how-to-convert-hex-to-decimal/#comment-65083</link>
		<dc:creator><![CDATA[Vedran Kesegic]]></dc:creator>
		<pubDate>Tue, 13 Apr 2010 07:49:41 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7785#comment-65083</guid>
		<description><![CDATA[There is no &#039;hex&#039; data type in sql server that we would convert from or to. We have hex literal (eg. 0xFFFF) which is int data type. We can have hex digits stored as ascii characters in varchar (e.g. &#039;FFFF&#039;, bytes 70,70,70,70 ), or as binary digits in varbinary (bytes 255, 255). You did not specify which sql type did you really want to convert from. If you want to convert from hex string to integer number, here it is:

DECLARE @hexstr VARCHAR(10); SET @hexstr = &#039;ffff&#039;
DECLARE @rez BIGINT; SET @rez = 0
WHILE @hexstr  &#039;&#039;
BEGIN
	SET @rez = @rez * 16 + CHARINDEX(LEFT(@hexstr,1),&#039;0123456789ABCDEF&#039;) - 1
	SET @hexstr = SUBSTRING(@hexstr,2,100)
END
PRINT @rez

Without loop, in one SELECT statement:

DECLARE @hexstr VARCHAR(10); SET @hexstr = &#039;ffff&#039;
DECLARE @rez BIGINT;
SELECT @rez = ISNULL(@rez,0) * 16 + CHARINDEX(substring(@hexstr,n.number+1,1),&#039;0123456789ABCDEF&#039;) - 1
FROM MASTER..spt_values n WHERE n.TYPE=&#039;P&#039; AND n.number&lt;len(@hexstr)
PRINT @rez

Vedran Kesegic]]></description>
		<content:encoded><![CDATA[<p>There is no &#8216;hex&#8217; data type in sql server that we would convert from or to. We have hex literal (eg. 0xFFFF) which is int data type. We can have hex digits stored as ascii characters in varchar (e.g. &#8216;FFFF&#8217;, bytes 70,70,70,70 ), or as binary digits in varbinary (bytes 255, 255). You did not specify which sql type did you really want to convert from. If you want to convert from hex string to integer number, here it is:</p>
<p>DECLARE @hexstr VARCHAR(10); SET @hexstr = &#8216;ffff&#8217;<br />
DECLARE @rez BIGINT; SET @rez = 0<br />
WHILE @hexstr  &#8221;<br />
BEGIN<br />
	SET @rez = @rez * 16 + CHARINDEX(LEFT(@hexstr,1),&#8217;0123456789ABCDEF&#8217;) &#8211; 1<br />
	SET @hexstr = SUBSTRING(@hexstr,2,100)<br />
END<br />
PRINT @rez</p>
<p>Without loop, in one SELECT statement:</p>
<p>DECLARE @hexstr VARCHAR(10); SET @hexstr = &#8216;ffff&#8217;<br />
DECLARE @rez BIGINT;<br />
SELECT @rez = ISNULL(@rez,0) * 16 + CHARINDEX(substring(@hexstr,n.number+1,1),&#8217;0123456789ABCDEF&#8217;) &#8211; 1<br />
FROM MASTER..spt_values n WHERE n.TYPE=&#8217;P&#8217; AND n.number&lt;len(@hexstr)<br />
PRINT @rez</p>
<p>Vedran Kesegic</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Curran</title>
		<link>http://blog.sqlauthority.com/2010/02/01/sql-server-question-how-to-convert-hex-to-decimal/#comment-62430</link>
		<dc:creator><![CDATA[James Curran]]></dc:creator>
		<pubDate>Mon, 08 Mar 2010 16:16:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7785#comment-62430</guid>
		<description><![CDATA[OK, I&#039;m going to assume that we are starting with a string holding hex digits, and we wnat to convert that into a int.

declare @hex varchar(10);
set @hex = &#039;BD12&#039;;

declare @retval int;
set @reval = -- 48402 via some magic.

Now, this being the wacky world of SQL, the best solution is gonna be something involving a set operation on tables, so let&#039;s start with a permanaent table mapping hex digits to their values:

CREATE TABLE [HexDigits](
	[Digit] [char](1) NOT NULL,
	[Value] [int] NOT NULL,
 CONSTRAINT [PK_HexDigits] PRIMARY KEY CLUSTERED ([Digit] ASC) )

INSERT INTO [HexDigits] VALUES (&#039;0&#039;, 0);
INSERT INTO [HexDigits] VALUES (&#039;1&#039;, 1);
--  etc 
INSERT INTO [HexDigits] VALUES (&#039;E&#039;, 14);
INSERT INTO [HexDigits] VALUES (&#039;F&#039;, 15);

Then, given a similar (presumably temporary) table mapping digits in the string we want translated to their digit position (count from the right), such as this, 

CREATE TABLE [HexString](
	[Digit] [char](1) NOT NULL,
	[Pos] [int] NOT NULL
 CONSTRAINT [PK_HexString] PRIMARY KEY CLUSTERED ([Digit] ASC) ) 
INSERT INTO [HexString] VALUES (&#039;B&#039;, 4);
INSERT INTO [HexString] VALUES (&#039;D&#039;, 3);
INSERT INTO [HexString] VALUES (&#039;1&#039;, 2);
INSERT INTO [HexString] VALUES (&#039;2&#039;, 1);


Then we have the simple query

select SUM(POWER(16,(pos-1))*Value)
From HexString s, HexDigits d
where s.Digit = d.Digit


The trick here will be the convert the original string (&quot;BD12&quot;, in this example), into the rows if the HexString table.  I don&#039;t know of a good way to do that,  but I&#039;m sure someone knows a simple way to do that.]]></description>
		<content:encoded><![CDATA[<p>OK, I&#8217;m going to assume that we are starting with a string holding hex digits, and we wnat to convert that into a int.</p>
<p>declare @hex varchar(10);<br />
set @hex = &#8216;BD12&#8242;;</p>
<p>declare @retval int;<br />
set @reval = &#8212; 48402 via some magic.</p>
<p>Now, this being the wacky world of SQL, the best solution is gonna be something involving a set operation on tables, so let&#8217;s start with a permanaent table mapping hex digits to their values:</p>
<p>CREATE TABLE [HexDigits](<br />
	[Digit] [char](1) NOT NULL,<br />
	[Value] [int] NOT NULL,<br />
 CONSTRAINT [PK_HexDigits] PRIMARY KEY CLUSTERED ([Digit] ASC) )</p>
<p>INSERT INTO [HexDigits] VALUES (&#8217;0&#8242;, 0);<br />
INSERT INTO [HexDigits] VALUES (&#8217;1&#8242;, 1);<br />
&#8211;  etc<br />
INSERT INTO [HexDigits] VALUES (&#8216;E&#8217;, 14);<br />
INSERT INTO [HexDigits] VALUES (&#8216;F&#8217;, 15);</p>
<p>Then, given a similar (presumably temporary) table mapping digits in the string we want translated to their digit position (count from the right), such as this, </p>
<p>CREATE TABLE [HexString](<br />
	[Digit] [char](1) NOT NULL,<br />
	[Pos] [int] NOT NULL<br />
 CONSTRAINT [PK_HexString] PRIMARY KEY CLUSTERED ([Digit] ASC) )<br />
INSERT INTO [HexString] VALUES (&#8216;B&#8217;, 4);<br />
INSERT INTO [HexString] VALUES (&#8216;D&#8217;, 3);<br />
INSERT INTO [HexString] VALUES (&#8217;1&#8242;, 2);<br />
INSERT INTO [HexString] VALUES (&#8217;2&#8242;, 1);</p>
<p>Then we have the simple query</p>
<p>select SUM(POWER(16,(pos-1))*Value)<br />
From HexString s, HexDigits d<br />
where s.Digit = d.Digit</p>
<p>The trick here will be the convert the original string (&#8220;BD12&#8243;, in this example), into the rows if the HexString table.  I don&#8217;t know of a good way to do that,  but I&#8217;m sure someone knows a simple way to do that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Madhivanan</title>
		<link>http://blog.sqlauthority.com/2010/02/01/sql-server-question-how-to-convert-hex-to-decimal/#comment-60595</link>
		<dc:creator><![CDATA[Madhivanan]]></dc:creator>
		<pubDate>Wed, 03 Feb 2010 07:16:37 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7785#comment-60595</guid>
		<description><![CDATA[http://beyondrelational.com/blogs/madhivanan/archive/2010/02/03/converting-hexadcimal-to-decimal.aspx]]></description>
		<content:encoded><![CDATA[<p><a href="http://beyondrelational.com/blogs/madhivanan/archive/2010/02/03/converting-hexadcimal-to-decimal.aspx" rel="nofollow">http://beyondrelational.com/blogs/madhivanan/archive/2010/02/03/converting-hexadcimal-to-decimal.aspx</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Razvan Socol</title>
		<link>http://blog.sqlauthority.com/2010/02/01/sql-server-question-how-to-convert-hex-to-decimal/#comment-60536</link>
		<dc:creator><![CDATA[Razvan Socol]]></dc:creator>
		<pubDate>Tue, 02 Feb 2010 06:42:44 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7785#comment-60536</guid>
		<description><![CDATA[If you are using SQL Server 2008, you can simply use the built-in function CONVERT, with the style 1:

SELECT CONVERT(varchar(100),0x123456789abc123,1)+&#039;?&#039;
SELECT CONVERT(varbinary,&#039;0x0123456789ABC123&#039;,1)+0x0

Notice that on SQL Server 2005, the above queries will not yield an error, but you will get different results (the same as if we used style 0).

Source: http://msdn.microsoft.com/en-us/library/ms187928.aspx

Razvan]]></description>
		<content:encoded><![CDATA[<p>If you are using SQL Server 2008, you can simply use the built-in function CONVERT, with the style 1:</p>
<p>SELECT CONVERT(varchar(100),0x123456789abc123,1)+&#8217;?&#8217;<br />
SELECT CONVERT(varbinary,&#8217;0x0123456789ABC123&#8242;,1)+0&#215;0</p>
<p>Notice that on SQL Server 2005, the above queries will not yield an error, but you will get different results (the same as if we used style 0).</p>
<p>Source: <a href="http://msdn.microsoft.com/en-us/library/ms187928.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms187928.aspx</a></p>
<p>Razvan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Madhivanan</title>
		<link>http://blog.sqlauthority.com/2010/02/01/sql-server-question-how-to-convert-hex-to-decimal/#comment-60535</link>
		<dc:creator><![CDATA[Madhivanan]]></dc:creator>
		<pubDate>Tue, 02 Feb 2010 06:36:09 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7785#comment-60535</guid>
		<description><![CDATA[If it is integer make use of implicit convertion

SELECT CONVERT(VARBINARY(8), 659604),0x000A1094*1

If it is decimal, use cast function

SELECT CONVERT(VARBINARY(8), 659604.1),cast(0x07010001C9A56400 as decimal(12,2))


http://beyondrelational.com/blogs/madhivanan]]></description>
		<content:encoded><![CDATA[<p>If it is integer make use of implicit convertion</p>
<p>SELECT CONVERT(VARBINARY(8), 659604),0x000A1094*1</p>
<p>If it is decimal, use cast function</p>
<p>SELECT CONVERT(VARBINARY(8), 659604.1),cast(0x07010001C9A56400 as decimal(12,2))</p>
<p><a href="http://beyondrelational.com/blogs/madhivanan" rel="nofollow">http://beyondrelational.com/blogs/madhivanan</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marko Parkkola</title>
		<link>http://blog.sqlauthority.com/2010/02/01/sql-server-question-how-to-convert-hex-to-decimal/#comment-60495</link>
		<dc:creator><![CDATA[Marko Parkkola]]></dc:creator>
		<pubDate>Mon, 01 Feb 2010 11:26:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7785#comment-60495</guid>
		<description><![CDATA[I&#039;ve lately interested in Sql Server&#039;s CLR support so here goes.

First I enable CLR support on Sql Server.

EXEC sp_CONFIGURE &#039;clr enabled&#039; , &#039;1&#039;
GO
RECONFIGURE;
GO

Then I create a simple DLL assembly called DBClasses with a static class named StringFormatFunctions and a static method HexToInt.

public partial class StringFormatFunctions
{
    [SqlFunction(IsDeterministic = true)]
    public static int HexToInt(string input)
    {
        return int.Parse(input, System.Globalization.NumberStyles.HexNumber);
    }
}

Next I load it to Sql Server.

CREATE ASSEMBLY DBClasses
FROM &#039;C:\path\DBClasses.dll&#039;
WITH PERMISSION_SET = SAFE

Finally I create a little function for it.

CREATE FUNCTION HexToInt(@input nvarchar)
RETURNS int
AS
EXTERNAL NAME DBClasses.StringFormatFunctions.HexToInt

And now I can start to use it.

SELECT dbo.HexToInt(&#039;ffff&#039;)]]></description>
		<content:encoded><![CDATA[<p>I&#8217;ve lately interested in Sql Server&#8217;s CLR support so here goes.</p>
<p>First I enable CLR support on Sql Server.</p>
<p>EXEC sp_CONFIGURE &#8216;clr enabled&#8217; , &#8217;1&#8242;<br />
GO<br />
RECONFIGURE;<br />
GO</p>
<p>Then I create a simple DLL assembly called DBClasses with a static class named StringFormatFunctions and a static method HexToInt.</p>
<p>public partial class StringFormatFunctions<br />
{<br />
    [SqlFunction(IsDeterministic = true)]<br />
    public static int HexToInt(string input)<br />
    {<br />
        return int.Parse(input, System.Globalization.NumberStyles.HexNumber);<br />
    }<br />
}</p>
<p>Next I load it to Sql Server.</p>
<p>CREATE ASSEMBLY DBClasses<br />
FROM &#8216;C:\path\DBClasses.dll&#8217;<br />
WITH PERMISSION_SET = SAFE</p>
<p>Finally I create a little function for it.</p>
<p>CREATE FUNCTION HexToInt(@input nvarchar)<br />
RETURNS int<br />
AS<br />
EXTERNAL NAME DBClasses.StringFormatFunctions.HexToInt</p>
<p>And now I can start to use it.</p>
<p>SELECT dbo.HexToInt(&#8216;ffff&#8217;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: fly</title>
		<link>http://blog.sqlauthority.com/2010/02/01/sql-server-question-how-to-convert-hex-to-decimal/#comment-60492</link>
		<dc:creator><![CDATA[fly]]></dc:creator>
		<pubDate>Mon, 01 Feb 2010 10:07:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7785#comment-60492</guid>
		<description><![CDATA[hmm.. 
What about using built-in function Convert?

SELECT CONVERT(INT, 0x00000100)
SELECT CONVERT(VARBINARY(8), 256)

I do not pretend to be the author, but i am using this for a long time]]></description>
		<content:encoded><![CDATA[<p>hmm..<br />
What about using built-in function Convert?</p>
<p>SELECT CONVERT(INT, 0&#215;00000100)<br />
SELECT CONVERT(VARBINARY(8), 256)</p>
<p>I do not pretend to be the author, but i am using this for a long time</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Feodor</title>
		<link>http://blog.sqlauthority.com/2010/02/01/sql-server-question-how-to-convert-hex-to-decimal/#comment-59977</link>
		<dc:creator><![CDATA[Feodor]]></dc:creator>
		<pubDate>Wed, 20 Jan 2010 06:56:35 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7785#comment-59977</guid>
		<description><![CDATA[Here is one way to do it:

create function fn_HexToIntnt(@str varchar(16)) 
returns bigint as begin

select @str=upper(@str)
declare @i int, @len int, @char char(1), @output bigint
select @len=len(@str)
,@i=@len
,@output=case 
			when @len&gt;0 
				then 0 
			end
while (@i&gt;0)
begin
  select @char=substring(@str,@i,1), @output=@output
  +(ASCII(@char)
    -(case 
		when @char between &#039;A&#039; and &#039;F&#039; 
			then 55 
		else 
	  case 
		when @char between &#039;0&#039; and &#039;9&#039; 
			then 48 end
      end))
  *power(16.,@len-@i)
  ,@i=@i-1
end 
return @output
end]]></description>
		<content:encoded><![CDATA[<p>Here is one way to do it:</p>
<p>create function fn_HexToIntnt(@str varchar(16))<br />
returns bigint as begin</p>
<p>select @str=upper(@str)<br />
declare @i int, @len int, @char char(1), @output bigint<br />
select @len=len(@str)<br />
,@i=@len<br />
,@output=case<br />
			when @len&gt;0<br />
				then 0<br />
			end<br />
while (@i&gt;0)<br />
begin<br />
  select @char=substring(@str,@i,1), @output=@output<br />
  +(ASCII(@char)<br />
    -(case<br />
		when @char between &#8216;A&#8217; and &#8216;F&#8217;<br />
			then 55<br />
		else<br />
	  case<br />
		when @char between &#8217;0&#8242; and &#8217;9&#8242;<br />
			then 48 end<br />
      end))<br />
  *power(16.,@len-@i)<br />
  ,@i=@i-1<br />
end<br />
return @output<br />
end</p>
]]></content:encoded>
	</item>
</channel>
</rss>
