CREATE DATABASE Customers;
USE Customers;
CREATE TABLE Customer
(
customer_Id int,
First_Name Varchar(15)
);
INSERT INTO customer (customer_Id, First_Name)
VALUES ( (1, 'John') );
Error :
Msg 102, Level 15, State 1, Line 8
Incorrect syntax near ‘,’.
Here’s a screenshot for reference – can somebody help with this?
SQL
Sankershan Patil is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2
Your insert syntax is off, and the VALUES
clause should just be a single level list of CSV tuples:
INSERT INTO customer(customer_Id, First_Name)
VALUES
(1, 'John'),
(2, 'Jon'),
...;
Try removing the closing parenthesis [“);”] after the (1,”John”)
I assume you are using TSQL (Microsft SQL Server) since the error report looks similar to it, if that’s the case, you should remove the outer parenthesis () after keyword Values
.
For example:
INSERT INTO Table1(columns...)
VALUES
(vals1)
INSERT INTO Table1(columns...)
VALUES
(vals1),
(vals2),
...
Where each vals
is the combination of one row values.
To solve your problem:
INSERT INTO Customer(customer_Id, First_Name)
VALUES
(1, 'John')
vtvinh24 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.