Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Sep 2005
    Location
    Enschede, Overijssel, Netherlands
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Multiple Inserts in one Query (2000)

    Hello People,

    I got a question, Is it possible to make a query that can handle a multiple insert.
    some thing like:
    insert into tbl values (col1, col2)
    insert into tbl values (col1, col2)
    insert into tbl values (col1, col2)

    I tried searching for it in the lounge but couldn't find anything, also tried google

    edit: some more info. Actually not trying this in Acces, but I'm using an acces DB.
    The program I am using is a report tool (Crystal reports) To be able to generate an ToC I need to insert some data to a table, wel the inserting works when it is one sheet.
    Several it crates a String with multiple inserts, and then The query goes boom. (error)

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Multiple Inserts in one Query (2000)

    Welcome to Woody's Lounge!

    A SQL statement can contain only one INSERT INTO.

    If the data come from another table, you can do something like this:

    INSERT INTO tbl1 (col1, col2) SELECT col1, col2 FROM tbl2

    If you're working with separate values, you will have to execute a separate SQL statement for each set.

  3. #3
    New Lounger
    Join Date
    Sep 2005
    Location
    Enschede, Overijssel, Netherlands
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Multiple Inserts in one Query (2000)

    I already know that information. I also know that with using a macro, it is possible to use multiple query's.

    But it wasn't the info i was looking for.

    But tnx anyway

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Multiple Inserts in one Query (2000)

    Sometimes we can suggest workarounds, such as macros or VBA code, but we don't have any magic powers to make SQL behave differently than it is designed to behave. <img src=/S/sorry.gif border=0 alt=sorry width=15 height=15> If you explain what you are trying to accomplish instead of just asking a flat question, someone might be able to make a useful suggestion. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>
    Charlotte

  5. #5
    5 Star Lounger
    Join Date
    Nov 2004
    Location
    Wilmington, North Carolina, USA
    Posts
    1,196
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Multiple Inserts in one Query (2000)

    To run multiple queries, on a command button's On Click event use

    DoCmd.OpenQuery "query1"
    DoCmd.OpenQuery "query2"

    etc....where each query inserts into a different table.
    ____________________________
    Jeremy
    "If you spend more on coffee than on IT security, then you will be hacked. What&#39;s more, you deserve to be hacked." -Richard Clarke

Posting Permissions

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