data is like 4 persons in each row their ids and office region. person id office in 3 columns
+1
A:
you can perform multiple operations in a single sql query, just separate the insert statements with semicolons, e.g.
insert into table1 (field1,field2) values (value1,value2);
insert into table1 (field1,field2) values (value1,value2);
insert into table1 (field1,field2) values (value1,value2);
insert into table1 (field1,field2) values (value1,value2)
you can wrap in a transaction if necessary also
Steven A. Lowe
2009-01-17 05:58:45
Apparently your Jedi skills are about as good as mine.
Jason Lepack
2009-01-17 06:09:55
+1
A:
If you are inserting into a single table, you can write your query like this (maybe only in MySQL):
insert into table1 (First,Last) values ("Fred","Smith"),
("John","Smith"),
("Michael","Smith"),
("Robert","Smith");
too much php
2009-01-17 06:10:26
+2
A:
You can use INSERT with SELECT UNION ALL:
INSERT INTO MyTable (FirstCol, SecondCol)
SELECT 'First' ,1
UNION ALL
SELECT 'Second' ,2
UNION ALL
SELECT 'Third' ,3
...
Only for small datasets though, which should be fine for your 4 records.
DavGarcia
2009-01-17 06:16:23
+3
A:
In SQL Server 2008 you can insert multiple rows using a single SQL INSERT statement.
INSERT INTO Table ( Column1, Column 2 ) VALUES ( Value1, Value2 ), ( Value1, Value2 )
For reference to this have a look at MOC Course 2778A - Writing SQL Queries in SQL Server 2008.
Diago
2009-01-17 07:14:14