Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fewer Columns in INSERT than VALUES

Tags:

sql

sql-server

I am writing a stored procedure and have declared a table as part of the code. I get an error

There are fewer columns in the INSERT statement than values specified in the VALUES clause

Here's my code:

DECLARE @FullTaskList TABLE (fval INT)

INSERT INTO @FullTaskList(fval) 
VALUES ( (1), (2), (3), (4), (5) )

I would be very grateful if you can help me.

like image 562
akrastev Avatar asked Dec 14 '22 12:12

akrastev


1 Answers

You just have too many parentheses:

DECLARE @FullTaskList TABLE ( fval INT )
INSERT INTO @FullTaskList ( fval )
    VALUES (1), (2), (3), (4), (5);

Your syntax is interpreted as (1, 2, 3, 4, 5), which is five values in one row, rather than five rows with one value.

like image 50
Gordon Linoff Avatar answered Dec 18 '22 00:12

Gordon Linoff