CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2001
    Posts
    14

    Copy a record in access using ADO and an SQL string

    I am trying to copy a record held within an access database and create a new one from it using unbound data with ADO. How can I do this using a SQL string?


  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Copy a record in access using ADO and an SQL string

    Let's say we have two tables, Customers and Prospects which have identical field lists. Instead of working
    with two tables we can combine them into a single table with a Type field that identifies the type of
    person as a customer or a prospect. Here's the SQL statement:

    INSERT INTO Customers (CustID, CustType, CustName, CustPhone)
    SELECT ProspectID, "Prospect" As CustType, ProspectName, ProspectPhone
    FROM Prospects;

    Note: The Visual Basic help file topic for the INSERT INTO statement incorrectly states that if the table you
    are copying from has a counter field that you should not include the counter in the query. The fact is that
    you can include the counter field if the values don't violate the primary key in the destination table.


    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured