Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

INSERTing multiple rows

0 views
Skip to first unread message

metaperl

unread,
Nov 16, 2009, 9:21:29 AM11/16/09
to
How could I (under T-SQL) combine make this INSERT statements simpler:

INSERT INTO ig VALUES ('050016994' , 1999, 14.0)
INSERT INTO ig VALUES ('050016995' , 1999, 14.0)
INSERT INTO ig VALUES ('050016996' , 1999, 14.0)


I dont want to simply have 3 VALUES clauses for one INSERT:

INSERT INTO ig VALUES ('050016994' , 1999, 14.0) VALUES ( ...) VALUES
( ...)

But I want to somehow use a SELECT to "stream" the variable value in:

INSERT INTO ig (column_name, 1999, 14.0) (SELECT column_name FROM
table WHERE column_name BETWEEN '050016994' AND '050016996')

Lennart

unread,
Nov 16, 2009, 12:50:52 PM11/16/09
to

insert into ....
select column_name, 1999, 14.0 from T where ...

/Lennart

--CELKO--

unread,
Nov 18, 2009, 6:29:06 AM11/18/09
to
SQL Server 2008 finally has the table constructor syntax:

INSERT INTO ig
VALUES ('050016994' , 1999, 14.0),
('050016995' , 1999, 14.0),


('050016996' , 1999, 14.0);


>> I dont want to simply have 3 VALUES clauses for one INSERT: <<

Of course not! Your syntax was illegal.

>> But I want to somehow use a SELECT to "stream" the variable value in: <<

Unh? SQL is set-oriented; we insert a whole set and not a stream.

0 new messages