CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2001
    Location
    Wisconsin, USA
    Posts
    150

    Database updates

    There isn't a forum out here specific for SQL, and seeing as I am writing this in VB I figured I would post
    this question out here. The question:

    Is there a way to move data between 2 tables in a database? I know I could just query the information in one
    table, and then use the update statement to update the new table, and then delete the old information from
    the first table. But I want to know if there is a way to move information from table 1 to table 2. Example:

    Table 1 is a ticketheader table, containing various information about open tickets. Table 2 is the ticketheaderhistory
    table, which contains the same information as table 1, only the information in table 2 is all of the closed
    tickets. I want to take some information in table 1 and put it into table 2 when the ticket is closed/cashed out,
    without having to do a query, an update, and then a delete. Can this be done in one step? Can the information
    be moved from table 1 to table 2 in one step, thereby eliminating the need for query/update/delete method?


  2. #2
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: Database updates

    You cannot do this in one time, but you can do it in 2. You can use the SELECT INTO or the INSERT INTO ... SELECT FROM statements. These allow you to insert data from one table directly into another. Then all you need to do is to delete it from the first table.

    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

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