My apologies for posting off topic, but I'm not sure where to ask this (and
I know there are some SQL gurus in here). :)

I want to insert multiple records into a database in one whack without
looping. Something along these lines:

INSERT INTO myTable (myField) VALUES ('abc'),('cde'),('def')

I believe this syntax is supported by MySQL, but not SQL Server. Is there
an equivalent for SQL Server?

Any help is greatly appreciated.
Thanks,
Peter Foti

Re: SQL, inserting multiple records without looping by Chris

Chris
Fri Feb 06 11:18:36 CST 2004

"Peter Foti" <peter@Idontwantnostinkingemailfromyou.com> wrote in
message news:1027hmff5s1md1d@corp.supernews.com...
> My apologies for posting off topic, but I'm not sure where to ask this
(and
> I know there are some SQL gurus in here). :)
>
> I want to insert multiple records into a database in one whack without
> looping. Something along these lines:
>
> INSERT INTO myTable (myField) VALUES ('abc'),('cde'),('def')
>
> I believe this syntax is supported by MySQL, but not SQL Server. Is
there
> an equivalent for SQL Server?
>
> Any help is greatly appreciated.
> Thanks,
> Peter Foti
>
>

INSERT INTO myTable (myField)
SELECT 'abc' UNION ALL
SELECT 'cde' UNION ALL
SELECT 'def'



Re: SQL, inserting multiple records without looping by Richard

Richard
Fri Feb 06 11:31:48 CST 2004

If you are using SQL Server you could also built the insert statement..

insert into mytable (myfield) values ('abc')
insert into mytable (myfield) values ('cde')
insert into mytable (myfield) values ('def')

and then run the statement..

Rich


"Peter Foti" <peter@Idontwantnostinkingemailfromyou.com> wrote in message
news:1027hmff5s1md1d@corp.supernews.com...
> My apologies for posting off topic, but I'm not sure where to ask this
(and
> I know there are some SQL gurus in here). :)
>
> I want to insert multiple records into a database in one whack without
> looping. Something along these lines:
>
> INSERT INTO myTable (myField) VALUES ('abc'),('cde'),('def')
>
> I believe this syntax is supported by MySQL, but not SQL Server. Is there
> an equivalent for SQL Server?
>
> Any help is greatly appreciated.
> Thanks,
> Peter Foti
>
>



Re: SQL, inserting multiple records without looping by Peter

Peter
Fri Feb 06 13:47:08 CST 2004

Thanks for your suggestions. :)

-Peter