?
Solved

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

Posted on 2008-02-04
4
Medium Priority
?
1,731 Views
Last Modified: 2008-03-06
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

0
Comment
Question by:hennessym
  • 2
  • 2
4 Comments
 
LVL 28

Expert Comment

by:TextReport
ID: 20818756
Can you please show examples of how these are held at the moment.
Cheers, Andrew
0
 
LVL 1

Author Comment

by:hennessym
ID: 20819087
Well, let's say the ip address = 127.0.0.1.  The field value =  7F000001.
0
 
LVL 28

Accepted Solution

by:
TextReport earned 1000 total points
ID: 20819477
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
 
LVL 1

Author Comment

by:hennessym
ID: 20824114
Thanks, worked perfectly!
0

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…
Stellar Phoenix SQL Database Repair software easily fixes the suspect mode issue of SQL Server database. It is a simple process to bring the database from suspect mode to normal mode. Check out the video and fix the SQL database suspect mode problem.
Suggested Courses

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question