Sarawut Positwinyu
Sarawut Positwinyu

Reputation: 5042

Is there any drawback of storing IP as Varchar

I have read a lot of topic here and people tend to store IP Address as int or Byte[], what are the drawback of storeing ip address as varchar ?

Upvotes: 0

Views: 261

Answers (2)

infojolt
infojolt

Reputation: 5418

Storing as a varchar will take up more space in your database. By converting and storing as an int, you will have less storage requirements. More of an issue if you have a lot of rows.

It is a bit out of date, but more info here: http://web.archive.org/web/20150511204915/http://sqlserver2000.databases.aspfaq.com/how-should-i-store-an-ip-address-in-sql-server.html

Upvotes: 1

Daan
Daan

Reputation: 455

My guess is that it is harder to look up a certain ip, when stored in a varchar and it also needs more space to be stored. Disadvantage is that, in order to store it as an integer, you need to convert it first to remove the dots.

Upvotes: 1

Related Questions