jsakamoto / ipaddressrange

.NET Class Library for range of IP address, both IPv4 and IPv6.
Mozilla Public License 2.0
370 stars 71 forks source link

Recommended SQL Server data type? #46

Open mwoffenden opened 6 years ago

mwoffenden commented 6 years ago

What is the recommended SQL Server data type for use with this to store IP addresses?

manigandham commented 5 years ago

Single addresses? IPv4 can be stored as integers (since that's what they are). Otherwise, or if you need IPv6, use binary to store the raw bytes or varchar to store as a string.

If you need ranges then there's no easy way. Simplest would be to store the max and min values separately, and the range too as a string just in case.