【问题标题】:Insert multiple values into SQL Server table将多个值插入 SQL Server 表
【发布时间】:2015-04-25 19:25:28
【问题描述】:

我是使用 SQL Server 的新手,我遇到了这个问题。我不知道如何连接才能在一个列表中插入多个值。

INSERT INTO Table (Column) 
VALUES ('Name'+','+' Last name',);,('Name'+','+'Last name',);

我得到这个错误:

消息 102,第 15 级,状态 1,第 3 行
',' 附近的语法不正确。

【问题讨论】:

标签: sql-server


【解决方案1】:
INSERT INTO Table (Column) 
VALUES ('Name'+','+ 'Last name')  --<-- no comma required inside the paranthesis
      ,('Name'+','+ 'Last name');  --<-- only need semi-colon here

【讨论】:

    【解决方案2】:

    使用应该使用||连接符号。 示例:SELECT first_name || ' ' || last_name FROM hr.employees;

    【讨论】:

    • 这是用于 sql server 的。您不能使用 || 连接
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多