我试图简单地在表中添加一些数据,但收到一个错误:
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.
下面是我正在使用的
INSERT INTO dbo.ReModalities
(ModalityId, Name, Description)
VALUES
(
1,'A','A.',
2,'B','B.'
);
这将使您对表列有一个大致的了解
INSERT INTO [XXX].[dbo].[ReModalities]
([ModalityId]
,[Name]
,[Description])
VALUES
(<ModalityId, int,>
,<Name, nvarchar(64),>
,<Description, nvarchar(256),>)
GO
另外,我想知道是否有方法可以避免键入if (表有PK,因此它们应该是自动创建的)非常感谢!
发布于 2012-06-25 17:36:45
values
语句的每一行都应该用括号括起来。尝试:
VALUES
(1,'A','A.'),
(2,'B','B.');
如果ID有默认值或为identity
,则可以省略:
insert dbo.ReModalities
(Name, Description)
values ('A','A.'),
('B','B.');
https://stackoverflow.com/questions/11186762
复制相似问题