Error message 110 is a commonly encountered error in SQL Server when inserting data into a table. The full error looks like this:
Msg 110, Level 15, State 1, Line 1 There are fewer columns in the INSERT statement than values specified in the VALUES clause. The number of values in the VALUES clause must match the number of columns specified in the INSERT statement.
This happens when you specify less columns in the INSERT
statement than the number of values that you’re trying to insert with the VALUES
clause.
This will occur if you accidentally omit one or more columns from the INSERT
statement.
You’d get a similar (but technically different) error if you tried to do the opposite – specify more columns in the INSERT
statement than you try to insert.
Example
Here’s an example to demonstrate.
INSERT INTO Customers (FirstName)
VALUES ('Bob', 'Brown');
Result:
Msg 110, Level 15, State 1, Line 1 There are fewer columns in the INSERT statement than values specified in the VALUES clause. The number of values in the VALUES clause must match the number of columns specified in the INSERT statement.
In this case, I specify one columns to insert data into (FirstName
), but I then specify two values to insert (Bob
and Brown
).
How to Fix the Error
You can fix this error by making sure the number of columns match the number of values to be inserted.
In my example, I could either remove one of the values to be inserted, or add a second column to cater for the second value.
So I could do this:
INSERT INTO Customers (FirstName)
VALUES ('Bob');
Or this:
INSERT INTO Customers (FirstName, LastName)
VALUES ('Bob', 'Brown');
It’s worth mentioning that if the LastName column has a NOT NULL
constraint, the first example will violate that constraint (because I’d be attempting to insert NULL
into the LastName column when there’s actually a NOT NULL
constraint on that column).
If there are only two columns in the table, I could also do this:
INSERT INTO Customers
VALUES ('Bob', 'Brown');
Although it’s usually better to explicitly state the column names if possible (as in the previous example).