Alex Rivera | Logout

Datatype for storing ip address in SQL Server

Asked 2009-09-06T12:22:39.567
132

What datatype should I choose for storing an IP Address in a SQL Server?

By selecting the right datatype would it be easy enough to filter by IP address then?

Edit
Report

1 Answer

36

You can use varchar. The length of IPv4 is static, but that of IPv6 may be highly variable.

Unless you have a good reason to store it as binary, stick with a string (textual) type.

answered 2009-09-06T12:31:08.173

Your Answer