INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

SELECT INTO

SELECT INTO

(OP)
Can the Select Into statement be used to insert data from one table to another table that already exists?  I can insert data into a new table, but not into one that already exists.   

David Paulson

 

RE: SELECT INTO

(OP)
I'm using Jet.  
Here's an example

SELECT QtyOnHand, UnitCost, ItemID FROM Inventory
and insert those values into another table (InvTransactions_Detail).  I know that I can create a recordset and loop though it and do an insert into command, but I was trying to learn a new way using just the connection.execute command.  I have managed to do exactly this with the select into , but only into a new table and not into an existing table.

David Paulson

 

RE: SELECT INTO

As I mentioned, you can use INSERT INTO.

INSERT INTO InvTransactions_Detail (QtyOnHand, UnitCost, ItemID)
SELECT QtyOnHand, UnitCost, ItemID
FROM Inventory


The query design window can be useful for creating examples of SQL. Build the query and then look at SQL view. You mat need to clean the SQL up a bit.

You can post on Jet SQL in forum701: Microsoft: Access Queries and JET SQL.


 

http://lessthandot.com

RE: SELECT INTO

(OP)
It looks simple enough now that I see it.  I've tried the sql statement.  It produces no errors, but it neither inserts any rows.  But at least it a start.  I'll play with it some more.  Thanks for the link to the SQL forum.  I've been a member here for > 7 years and never new it existed. Thanks again

David Paulson

 

RE: SELECT INTO

Are there any records in Inventory? Are duplicate records allowed in InvTransactions_Detail? If you are using CurrentDB.Execute, you must use dbFailOnError, if you do not wish the SQL to fail silently.

http://lessthandot.com

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close