Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inserting Multiple Rows in Sybase ASE

(Similar question related to SQL Server : SO Link)

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

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

However, it seems like this syntax DOES NOT work in Sybase Adaptive Server Enterprise, since this gives me an error..

Anyone know the syntax in Sybase that achieves the same thing?

Sybase ASE is based on Transact SQL..

Thanks

like image 275
user2436815 Avatar asked Jul 08 '14 15:07

user2436815


Video Answer


2 Answers

Sybase doen't have insert syntax as SQL Server. What's wrong with showed below classic method?

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
like image 90
Robert Avatar answered Oct 05 '22 18:10

Robert


try this:

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

I know this works on older versions of SQL server, and suspect that it will work with sybase.

like image 36
George Mastros Avatar answered Oct 05 '22 19:10

George Mastros