views:

437

answers:

1

I messed up. I wanted to store IP addresses compactly in SQL Server and chose 'int' for the column type. 'int' are 32 bit signed integers while IPs really are 32 bit binarys.

My question is: How do I convert my existing signed int into Binary(4) in SQL Server and how should I properly parse the string-IP representation from .Net 'Request.UserHostAddress' to get Binary(4) (I'm using LinqtoSQL as my ORM).

+2  A: 

Here is a good article about storing IP address data in SQL Server

Raj More