Question

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).

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top