SQL Server : The number of row value expressions in the INSERT statement exceeds the maximum allowed number of 1000 row values
Apr 16, 2024
Assume you have an error message in the Dbeaver or database tools and you have the code that looks like this
INSERT INTO my_table (code, title, desc) VALUES
('111', 'my_foo', 'foo'),
('222', 'my_bar', 'bar'),
('333', 'my_baz', 'baz'),
...
Workaround 1: Every line INSERT
INSERT INTO my_table (code, title, desc) VALUES ('111', 'my_foo', 'foo');
INSERT INTO my_table (code, title, desc) VALUES ('222', 'my_bar', 'bar');
INSERT INTO my_table (code, title, desc) VALUES ('333', 'my_baz', 'baz');
...
Workaround 2: Union or Union All
INSERT INTO my_table (code, title, desc)
SELECT '111', 'my_foo', 'foo'
UNION ALL SELECT '222', 'my_bar', 'bar'
UNION ALL SELECT '333', 'my_baz', 'baz'
...
Hope this help !