I have a wrong syntax error

INSERT INTO FoodLog
(Person,Food,ServingSize,Date,Meal)
VALUES
('John','Cheerios',2,'1-APR-2014','Breakfast')
('John','TBoneSteak',1,'2-APR-2014','Lunch')

In this code, the first line of code works fine, but when I enter the second line of code with the same name, it does not accept it.

This is the error I get:

Msg 102, Level 15, State 1, Line 5
Invalid syntax next to John.

+4
source share
2 answers

For the sake of an answer, not a comment. Just like @helderdarocha said: "You are missing a comma between the lines."

INSERT INTO FoodLog (Person,Food,ServingSize,Date,Meal)
VALUES ('John','Cheerios',2,'1-APR-2014','Breakfast')
      ,('John','TBoneSteak',1,'2-APR-2014','Lunch')
+3
source

As @helderdarocha and @Karl Kieninger said you don’t see a comma between tuples or if you still cannot solve the problem, try writing separate entries .... I can’t think of anything else ...

    INSERT INTO FoodLog VALUES ('John','Cheerios',2,'1-APR-2014','Breakfast');
    INSERT INTO FoodLog VALUES ('John','TBoneSteak',1,'2-APR-2014','Lunch');
+2

Source: https://habr.com/ru/post/1537159/


All Articles