Insert multiple rows in Sybase ASE

(A similar question related to SQL Server: SO Link )

I know in Sql Server 2008 or higher, you can insert multiple rows by doing the following:

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

However, this syntax does NOT seem to work in Sybase Adaptive Server Enterprise, as it gives me an error.

Does anyone know the syntax in Sybase that achieves the same?

Sybase ASE is based on Transact SQL ..

thank

+5
source share
4 answers

Sybase does not have insert syntax like SQL Server. What is wrong with the classic method shown below?

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
+8
source

try the following:

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

, SQL-, , sybase.

+2

, Sybase ASE, , SO, UNION ALL,

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

SQL Server Sybase. , UNION ALL

0

Source: https://habr.com/ru/post/1547607/


All Articles