Reputation: 74008
I'm trying to simply adding some data in a table but I receive an error:
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.
Here what I'm using
INSERT INTO dbo.ReModalities
(ModalityId, Name, Description)
VALUES
(
1,'A','A.',
2,'B','B.'
);
This should give you an idea of the Table Column
INSERT INTO [XXX].[dbo].[ReModalities]
([ModalityId]
,[Name]
,[Description])
VALUES
(<ModalityId, int,>
,<Name, nvarchar(64),>
,<Description, nvarchar(256),>)
GO
Also I would like to know if there is way I can avoid typing the IDs (the table has PK so they should be created automatically) many thanks!
Upvotes: 0
Views: 7197
Reputation: 238296
Each row of the values
statement should be enclosed in parenthesis. Try:
VALUES
(1,'A','A.'),
(2,'B','B.');
If the ID has a default value or is an identity
, you can omit it:
insert dbo.ReModalities
(Name, Description)
values ('A','A.'),
('B','B.');
Upvotes: 5