Results 1 to 7 of 7
  1. #1
    Join Date
    Jul 2004
    Posts
    494

    Unanswered: Any code for automatically inserting queries of first table into the second?

    Any code for automatically inserting queries of first table into the second?
    Is there a way of inserting the query of records from the first table into the second? Because I want to use the second db by deleting records that might be unnecessary.

    I want to copy the searches of one table to another. Let's say I search a keyword I want the search to go through the first table and copy the records where the keyword is to be found to the second table. I find that would be easy to study. Whatever I don't want from that search I can easily delete it. And at the same time I have the original table not tampered.

  2. #2
    Join Date
    Sep 2004
    Posts
    16
    could u just

    INSERT INTO Table2 (field1)
    SELECT * FROM Table1;

    i believe u can just use the INSERT cmd

  3. #3
    Join Date
    Jul 2004
    Posts
    494

    ok...

    Is it before or after (I'd guess it's before) the
    HTML Code:
    <%rs.Open SQL%>
    statement?

  4. #4
    Join Date
    Jul 2004
    Posts
    494

    execute problem

    What does this mean?

    INSERT INTO results(id, book, book_spoke, recordType, book_title, chap, chapter, chapter_spoke, vers, verse, verse_spoke, text_data) VALUES (, , , '', '', , , , , , , '')
    Microsoft VBScript runtime error '800a01b6'

    Object doesn't support this property or method: 'execute'

    /kjvresp.asp, line 280

  5. #5
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    the problem is here: VALUES (, , , '', '', , , , , , , '')

    you have to put something for each column

    at worst, you could use nulls (assuming the table allows nulls)

    VALUES (null, null, null, '', '', null, null, null, null, null, null, '')
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  6. #6
    Join Date
    Jul 2004
    Posts
    494

    That was because...

    I had put && around each fieldname. But I made some changes. But this is what I got now:

    INSERT INTO results SELECT * FROM bible WHERE text_data LIKE '%ezra%' AND text_data LIKE '%%' AND text_data LIKE '%%'
    Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

    [Microsoft][ODBC Microsoft Access Driver] The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again.

    /kjvresp.asp, line 272
    The insertion was found in the table but the output to the ASP page is somehow blocked.

  7. #7
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    text_data LIKE '%%' is true for every row and should be dropped

    if you have an ASP problem, you should post in the ASP forum

    this forum is for generic (non-proprietary) SQL
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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