Msg 102, Level 15, State 1, Line 2 Incorrect syntax near ',' trying to insert INTO
I have successfully created db and tables, but when I try to populate one of the tables like
INSERT INTO Products(IsProductActive,ProductName,ProductCount)
VALUES(0,'productName1',0),
(0,'productName2',0),
(1,'productName3',9),
(1,'productName4',7),
(1,'productName5',3),
(1,'productName6',10),
(0,'productName7',0),
(1,'productName8',6),
(1,'productName9',12),
(1,'productName10',20);
GO
i got the error:
Msg 102, Level 15, State 1,
Line 2 Incorrect syntax next to ','.
firstly, what does "," mean, and secondly - what is wrong? PS: I am using MS Management Studio v 9.0 if needed ...
+3
Sergii
source
to share
2 answers
SQL Server 2005 and below do not support multiple VALUE clause syntax
SQL Server 2005 is version 9 ...
See How to insert multiple rows WITHOUT repeating the "INSERT INTO dbo.Blah" part of the report? for more
+3
gbn
source
to share
if you use SQL SERVER 2005
below and below, the query won't work because it doesn't support the clause's insert statement. You have to insert it one by one.
As shown below,
INSERT INTO Products(IsProductActive,ProductName,ProductCount)
VALUES(0,'productName1',0)
GO
INSERT INTO Products(IsProductActive,ProductName,ProductCount)
VALUES(0,'productName2',0)
GO
0
John Woo
source
to share