Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Field Data Type To Store IP Address - MSSQL2000

Posted on 2006-11-15
Medium Priority
Last Modified: 2010-08-05
I would like to know what data type to set on a field to store IP addresses so that i can run a query against it.

I have it set to nText at the minute but i obviously cannot put a query against this data type.

Question by:net-workx
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 28

Assisted Solution

imran_fast earned 2000 total points
ID: 17946923
No set it to varchar(50)
LVL 29

Expert Comment

ID: 17946930
Why not varchar (or nvarchar)? (IP Address will only be a max of 15 characters)
LVL 28

Accepted Solution

imran_fast earned 2000 total points
ID: 17946942
the ip address will be in format


maximum 15 character so better make it varchar(15) or varchar(20)

LVL 29

Expert Comment

ID: 17946986
If you are storing a port number as well, it could be longer ;)

5 characters for maximum port number, 1 for space (or colon).
So 21 characters if you are storing it, 15 if not.

Featured Post

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how the fundamental information of how to create a table.

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question