Insert Multiple Rows SQL Teradata

Bocean picture Bocean · Sep 23, 2016 · Viewed 24.4k times · Source

I am creating a volatile table and trying to insert rows to the table. I can upload one row like below...


create volatile table Example
(
    ProductID VARCHAR(15),
    Price DECIMAL (15,2)
)
on commit preserve rows;
et;

INSERT INTO Example
Values
('Steve',4);

However, when I try to upload multiple I get the error:

"Syntax error: expected something between ')' and ','."

INSERT INTO Example
Values
('Steve',4),
('James',8);

Answer

dnoeth picture dnoeth · Sep 23, 2016

As Gordon said, Teradata doesn't support VALUES with multiple rows (and the UNION ALL will fail because of the missing FROM.

You can utilize a Multi Statement Request (MSR) instead:

INSERT INTO Example Values('Steve',4)
;INSERT INTO Example Values('James',8)
;

If it's a BTEQ job the Inserts are submitted as one block after the final semicolon (when there's a new command starting on the same line it's part of the MSR). In SQL Assistant or Studio you must submit it using F9 instead of F5.