In SQL Server, how do I convert Hex IP addresses to dotted ip addresses?

I have a table in SQL Server 2005 containing a number of hexadecimal ip addresses.  I'd like to convert them to dotted ip addresses, either via SQL or ASP.NET.

Can anyone offer tips on how to achieve this?

Thanks in advance,
Matt

LVL 1
hennessymAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TextReportCommented:
Can you please show examples of how these are held at the moment.
Cheers, Andrew
0
hennessymAuthor Commented:
Well, let's say the ip address = 127.0.0.1.  The field value =  7F000001.
0
TextReportCommented:
Ok real trouble finding code that will convert the VarChar Hex to Int but found some at http://digitalcolony.com/2007/06/convert-hexadecimal-to-integer-in-sql.aspx

You will need to create the function and then call it for the 4 parts of your IP address using
SUBSTRING(IPAddress,1,2) -- You Could use LEFT(IPAddress,2)
SUBSTRING(IPAddress,3,2)
SUBSTRING(IPAddress,5,2)
SUBSTRING(IPAddress,7,2) -- You Could use RIGHT(IPAddress,2)

Cheers, Andrew
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hennessymAuthor Commented:
Thanks, worked perfectly!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.