-3
INSERT INTO ServiceID_302
 (Services)
 VALUES (
('Preliminaries'),
 ('Demolition'),
 ('DRAINAGE_AND_REFUSE_DISPOSAL'),
 ('GAS_DISTRIBUTION-COMPRESSED_AIR'),
 ('SPACE_COOLING-CHILLED_WATER'),
 ('SPACE_HEATING-LOW_PRESSURE_HOT_WATER'),
 ('VENTILATION_&_AIR_CONDITIONING'),
 ('OTHER_MECHANICAL_SERVICES'),
 ('Sprinkler'),
 ('Dayworks'),
 ('COMMERCIAL_DISCOUNT'),
 ('VARIATIONS')
 );

I am trying to insert this using inline query it throws an error :

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.'

I have this structure where id is primary key also its a identity column

     SELECT [Id]
          ,[Services]
      FROM [CostManagement].[dbo].[ServiceID_302]
4
  • This looks like SQL Server, but the tags explicitly indicate MySQL. Can you clarify? And how is C# involved? Commented Jun 18, 2024 at 11:28
  • You don't need the outer braces to wrap all data rows to be inserted. Remove the outer opening and closing braces: INSERT INTO ServiceID_302 (Services) VALUES ('Preliminaries'), ..., ('VARIATIONS'); Commented Jun 18, 2024 at 11:30
  • What do you mean by 'inline query'? Commented Jun 18, 2024 at 11:32
  • You're trying to insert a single row with 12 columns where one column is expected, not 12 rows with one column. Parentheses have significant meaning here. Commented Jun 20, 2024 at 10:22

1 Answer 1

2

Brackets are more than needed. Remove the ones that wraps all Values

INSERT INTO ServiceID_302
 (Services)
 VALUES 
 ('Preliminaries'),
 ('Demolition'),
 ('DRAINAGE_AND_REFUSE_DISPOSAL'),
 ('GAS_DISTRIBUTION-COMPRESSED_AIR'),
 ('SPACE_COOLING-CHILLED_WATER'),
 ('SPACE_HEATING-LOW_PRESSURE_HOT_WATER'),
 ('VENTILATION_&_AIR_CONDITIONING'),
 ('OTHER_MECHANICAL_SERVICES'),
 ('Sprinkler'),
 ('Dayworks'),
 ('COMMERCIAL_DISCOUNT'),
 ('VARIATIONS') 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.