Sql 在Sybase ASE中插入多行

Sql 在Sybase ASE中插入多行,sql,sql-server,database,tsql,sybase,Sql,Sql Server,Database,Tsql,Sybase,(与SQL Server相关的类似问题:) 我知道在Sql Server 2008或更高版本中,您可以插入多行,执行以下操作: INSERT INTO MyTable (Name, ID) VALUES ('First',1), ('Second',2), ('Third',3) 但是,这种语法似乎在Sybase Adaptive Server Enterprise中不起作用,因为这给了我一个错误 有人知道Sybase中实现相同功能的语法吗 Sybase ASE基于Transact-SQL 谢

(与SQL Server相关的类似问题:)

我知道在Sql Server 2008或更高版本中,您可以插入多行,执行以下操作:

INSERT INTO MyTable (Name, ID)
VALUES ('First',1), ('Second',2), ('Third',3)
但是,这种语法似乎在Sybase Adaptive Server Enterprise中不起作用,因为这给了我一个错误

有人知道Sybase中实现相同功能的语法吗

Sybase ASE基于Transact-SQL

谢谢

试试这个:

INSERT INTO MyTable (Name, ID)
Select 'First',1
Union All 
Select 'Second',2
Union All
Select 'Third',3

我知道这适用于较旧版本的SQL server,并怀疑它将适用于sybase。

看起来该语法在sybase ASE中无效,但正如链接文章中所建议的,因此您可以使用
UNION ALL
获得相同的语法

INSERT INTO MyTable (Name, ID)
SELECT 'First',1
UNION ALL
SELECT 'Second',2
UNION ALL
SELECT 'Third',3

Sybase没有SQL Server那样的插入语法。下面显示的经典方法有什么问题

INSERT INTO MyTable (Name, ID) VALUES ('First',1)
INSERT INTO MyTable (Name, ID) VALUES ('Second',2)
INSERT INTO MyTable (Name, ID) VALUES ('Third',3)
go

此示例中SQL Server中的语法在Sybase中不起作用。要么使用单个语句,要么使用UNION ALL子句

有什么“错误”,或者更麻烦的是,您必须不断重复
插入MyTable(Name,ID)值
@Joel您的Sybase版本是什么?这也适用于参数化值:…选择?,?联合所有。。。