HShbib
HShbib

Reputation: 1841

Error in an Insert command

below is my insert command I am trying to insert IP addresses into a record in the table. The IP_Address attribute has nvarchar datatype. However the error shows under the number 206 in the IP address

Code:

INSERT INTO [IP_Loc].[dbo].[IP_Addresses] (IP_Address) VALUES (98.137.206.119,98.137.206.126)

Msg 102, Level 15, State 1, Line 2 Incorrect syntax near '.206'.

Any idea what the problem might be ?

Upvotes: 0

Views: 60

Answers (3)

Oded
Oded

Reputation: 498904

Two issues - an NVARCHAR that is not enclosed in ', and a VALUES that has two values, instead of ONE:

INSERT INTO [IP_Loc].[dbo].[IP_Addresses] (IP_Address) 
VALUES ('98.137.206.119'),
('98.137.206.126')

Upvotes: 5

xlecoustillier
xlecoustillier

Reputation: 16351

INSERT INTO [IP_Loc].[dbo].[IP_Addresses] (IP_Address) VALUES ('98.137.206.119');
INSERT INTO [IP_Loc].[dbo].[IP_Addresses] (IP_Address) VALUES ('98.137.206.126');

Upvotes: 1

Carlos Landeras
Carlos Landeras

Reputation: 11063

Try with:

INSERT INTO [IP_Loc].[dbo].[IP_Addresses] (IP_Address) VALUES ('98.137.206.119','98.137.206.126')

It seems you are missing the quotes ''

If the table only have one column you will need to do it like:

 INSERT INTO [IP_Loc].[dbo].[IP_Addresses] (IP_Address) VALUES ('98.137.206.119')
 INSERT INTO [IP_Loc].[dbo].[IP_Addresses] (IP_Address) VALUES ('98.137.206.126')

Upvotes: 3

Related Questions