1

I am creating database for a website and want to store IP Address of user when they are login, what data type should I be using for IP? does it need to support IPv6?

Is this script good and does it need to pars IP?

CREATE TABLE [dbo].[temp](
    [id] [bigint] IDENTITY(1,1) NOT NULL,
    [userId] [bigint] NOT NULL,
    [ip] [varchar](40) NOT NULL,
    [dateTime] [datetime] NOT NULL,
 CONSTRAINT [PK_temp] PRIMARY KEY CLUSTERED 
(
    [id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
Srinivas
  • 1,780
  • 1
  • 14
  • 27
Mahyar
  • 796
  • 4
  • 16
  • 34
  • you might be interested in this http://stackoverflow.com/questions/1385552/datatype-for-storing-ip-address-in-sql-server – bummi Dec 22 '12 at 08:26
  • See [Maximum length of the textual representation of an IPv6 address?](http://stackoverflow.com/questions/166132/maximum-length-of-the-textual-representation-of-an-ipv6-address) – peterm Dec 22 '12 at 08:27
  • bummi peterm thanks for your links, is it importent to have IPv6? – Mahyar Dec 22 '12 at 09:10

1 Answers1

0

Here is the link which describes how to store IP addresses in database.

Community
  • 1
  • 1
Jirilmon
  • 1,924
  • 1
  • 12
  • 13