Help with inserting values from information not found in another table

Discussion in 'ASP General' started by Joey Martin, Jul 16, 2003.

  1. Joey Martin

    Joey Martin Guest

    I have a tmp_phone that I am comparing to table_phonelistings using the
    phone field.

    I then want to insert the values (ac,phone) from the tmp_phone table NOT
    IN table_phonelistings, into the table_phonelistings.

    I think I am doing an incorrect loop as it's timing out. Any help is
    appreciated. Here is what I have:

    sql2="select ac,phone from tmp_phone where phone not in (select phone
    from table_phonelistings)"
    set rs=conn.execute(sql2)
    sql3="insert into table_phonelistings (areacode,phone) values ('" &
    rs("ac") & "','" & rs("phone") & "')"
    conn.execute(sql3)
    do while not rs.eof
    loop
    conn.close



    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Joey Martin, Jul 16, 2003
    #1
    1. Advertising

  2. Joey Martin

    Bob Barrows Guest

    Only one SQL command is needed:

    sql = "Insert into table_phonelistings (areacode,phone) " & _
    "Select ac,phone from tmp_phone where phone not in " & _
    "(select phone from table_phonelistings)"

    conn.execute sql,,1 '1=adCmdText

    see below for an explanation of your time out:

    Joey Martin wrote:
    > do while not rs.eof


    You don't have any code inside this loop! of course it's timing out. Well,
    you don't need the loop anyways.

    > loop


    HTH,
    Bob Barrows
    Bob Barrows, Jul 16, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Child
    Replies:
    3
    Views:
    324
    John Timney \(Microsoft MVP\)
    Aug 8, 2003
  2. Bijoy Naick

    Inserting Records from another table

    Bijoy Naick, Jun 30, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    342
    Steve C. Orr [MVP, MCSD]
    Jun 30, 2004
  3. clercmedia
    Replies:
    2
    Views:
    32,278
    clercmedia
    Dec 9, 2005
  4. lerenard001
    Replies:
    0
    Views:
    421
    lerenard001
    Jul 7, 2008
  5. Fawke101

    Inserting values into a table

    Fawke101, Apr 2, 2004, in forum: ASP General
    Replies:
    5
    Views:
    95
    Jeff Cochran
    Apr 2, 2004
Loading...

Share This Page