Friday, February 23, 2007

How should I store an IP address in SQL Server?

I had the mis-fortune of working with a database where the developers decided to store the IP address as an integer. I believe they did this in order to help improve the performance of their database, or storage, or possibly both. The front end dealt with all the conversion of IP to INT and vice versa. When I needed to make a little bit of enhancements because the front end was just literally timing out at the amount of data that it needed. I decided to change how I retrieved some of my reports, and thus run into the following link, in where the author shares two functions to aid in the conversion of IP to INT and INT to IP. The article is quite good and even has a few numbers on what the performance is on each style of how one might choose to store the IP address information.

How should I store an IP address in SQL Server?


I know my new years resolution was going to be broken the moment I published the first article of the year :D HA!. I do have an article on working with indexes and hopefully it should be quite good. Stay tuned!