gpt4 book ai didi

SQL 服务器 2008 : Trying to insert multiple rows using 1 SQL Statement

转载 作者:行者123 更新时间:2023-12-05 08:44:36 26 4
gpt4 key购买 nike

我需要向 SQL Server 2008 中插入 50 多行,但出现了一个奇怪的错误。请帮忙!

表格设计:

  • 姓名:mod_Facilities
  • 专栏
    • faclityID、主键/索引
    • 设施名称,nvarchar(4000)
    • 设施描述,nvarchar(4000)
    • 状态注释,nvarchar(4000)
    • isPublic, 位
    • isActive, 位
    • 已删除,位

错误:

Msg 102, Level 15, State 1, Line 3 Incorrect syntax near ','.

这是我的 SQL 语句

INSERT INTO mod_Facilites (facilityName,facilityDescription,isActive,isDeleted)
VALUES
('Conference Room Lower','Conference Room Lower – 25, (AV ready for meetings and info sessions)','true','false'),
('Conference Room Upper','Conference Room Upper – 21, (AV ready for meetings and info sessions)','true','false'),
('Meeting Room A','Meeting Room A – (upper theatre set up capacity 40) ','true','false'),
('Meeting Room B','Meeting Room B – (AV ready classroom set up capacity 25) ','true','false'),
('Meeting Rooms A & B','Meeting Rooms A & B – (AV ready capacity 80)','true','false'),
('OP Resource Room','OP Resource Room','true','false'),
('Climbing Wall','Climbing Wall','true','false'),
('Bouldering Wall','Bouldering Wall','true','false'),
('Entire Climbing Area','Entire Climbing Area','true','false'),
('CPR/First Aid classroom','CPR/First Aid classroom','true','false'),
('Lobby Area','Lobby Area','true','false'),
('Studio 1','Studio 1 ','true','false'),
('Studio 2','Studio 2','true','false'),
('Studio 3','Studio 3','true','false'),
('Studio 4','Studio 4','true','false'),
('Mat Studio','Mat Studio','true','false');

最佳答案

您将此问题标记为 SQL Server 2008,但这正是您在 2005 或更早版本上尝试此语法时看到的错误。

作为替代方案,请尝试:

INSERT INTO mod_Facilites 
(facilityName,facilityDescription,isActive,isDeleted)
SELECT 'Conference Room Lower','Conference Room Lower – 25, (AV ready for meetings and info sessions)','true','false' UNION ALL
SELECT 'Conference Room Upper','Conference Room Upper – 21, (AV ready for meetings and info sessions)','true','false' UNION ALL
SELECT 'Meeting Room A','Meeting Room A – (upper theatre set up capacity 40) ','true','false' UNION ALL
SELECT 'Meeting Room B','Meeting Room B – (AV ready classroom set up capacity 25) ','true','false' UNION ALL
SELECT 'Meeting Rooms A & B','Meeting Rooms A & B – (AV ready capacity 80)','true','false' UNION ALL
SELECT 'OP Resource Room','OP Resource Room','true','false' UNION ALL
SELECT 'Climbing Wall','Climbing Wall','true','false' UNION ALL
SELECT 'Bouldering Wall','Bouldering Wall','true','false' UNION ALL
SELECT 'Entire Climbing Area','Entire Climbing Area','true','false' UNION ALL
SELECT 'CPR/First Aid classroom','CPR/First Aid classroom','true','false' UNION ALL
SELECT 'Lobby Area','Lobby Area','true','false' UNION ALL
SELECT 'Studio 1','Studio 1 ','true','false' UNION ALL
SELECT 'Studio 2','Studio 2','true','false' UNION ALL
SELECT 'Studio 3','Studio 3','true','false' UNION ALL
SELECT 'Studio 4','Studio 4','true','false' UNION ALL
SELECT 'Mat Studio','Mat Studio','true','false';

关于SQL 服务器 2008 : Trying to insert multiple rows using 1 SQL Statement,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5249913/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com