Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mutiple insert into command

Status
Not open for further replies.

rcj2

Technical User
Joined
Feb 15, 2003
Messages
4
Location
US
I want to insert mutiple employees into a table with the INSERT INTO command. Is there a way to group mutiple INSERT INTO commands into one query and insert them all at once?
Here is an example of what I have:

INSERT INTO tblEmploy ( employID, employSSN, employFName, employLName, employAddr, employCity, employState, employZcode, employPhone, employEmail, JobtitleID, employHireDate, employSalary )
VALUES ('9050667', '624356789', 'Jim', 'Crochie', '29 Glimmer Road', 'St. Chuck', 'Missouri', '54321', '6362963133', 'jcrochie@hotmail.com', '10210', '02281960', '89000.00')

INSERT INTO tblEmploy ( employID, employSSN, employFName, employLName, employAddr, employCity, employState, employZcode, employPhone, employEmail, JobtitleID, employHireDate, employSalary )
VALUES ('9050668', '654356789', 'Nick', 'Drake', '32 DOA Street', 'Branson', 'Missouri', '63054', '6366652100', 'ndrake@yahoo.com', '10208', '09221999', '40000.00')

INSERT INTO tblEmploy ( employID, employSSN, employFName, employLName, employAddr, employCity, employState, employZcode, employPhone, employEmail, JobtitleID, employHireDate, employSalary )
VALUES ('9050669', '124356712', 'Jenny', 'Jones', '69 Hope Drive', 'St. Chuck', 'Missouri', '63144', '3146469909', 'jjones@hotmail.com', '10206', '12242003', '23000.00')


Can I enter these all into one query and have it update the table all at once?

 
I don't think there is a way to include multiple, separate SQL statements like this in a single query.

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
The only way I know to insert multiples rows with a single instruction is this:
INSERT INTO ... SELECT ...
The INSERT INTO ... VALUES ... stands for ONE row.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PHV,

Could you provide me with a little more information on the insert select command.
 
The insert with a Select requires that your inserted values are contained in a table. This is a basic Append Query.

In your case, it doesn't look like you have your values stored in a table.

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
Yeah, dhookum is absolutely right. You can append a group of records using an append query.
 
rcj2, search your computer for file jet*.chm

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PHV,

Thanks for that helpful tip.
 
You can batch sql statements in most sql interfaces, I am not sure about DAO but ADO should support it. Just separate the sql statements with a semi colon. The only thing is that there is a size limit on a string field. I have done it with select statements but not insert statements but you could give it a try.

Dim avar as variant
Dim cn as New ADODB.Connection

avar = "insert into table; insert into table; etc...."

cn.Execute avar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top