Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2005
    Posts
    4

    Unanswered: Copy info from one table two another with conditions

    I am importing a csv file into a temp table (works fine), now I want to take the data in the temp table based off of the temp id compared to the id of the permanant file.

    basically if the record id exists skip to the next line and so forth, I am able to import everything just fine but I cannot get the WHERE condition to acually work.

    INSERT INTO TABLE2 (COL1, COL2, COL3) SELECT COL1, COL4, COL7 FROM TABLE1 WHERE table2.col1 <> table1.col1

    this is what my actual code is


    INSERT INTO USER_INFO (fpu_id,FIRSTNAME, LASTNAME, BOXNUMBER) SELECT id,first,last,box FROM stmailbox WHERE stmailbox.id <> dbo.USER_INFO.USERID

    this is the actual error that I get.

    Server: Msg 107, Level 16, State 3, Line 2
    The column prefix 'USER_INFO' does not match with a table name or alias name used in the query.

    -----
    thanks for the help
    Last edited by nhaas; 10-25-05 at 17:02.

  2. #2
    Join Date
    Oct 2005
    Posts
    4
    Well I think that I got it...

    INSERT INTO USER_INFO (id,FIRSTNAME, LASTNAME, BOXNUMBER) SELECT id,first,last,box FROM stmailbox WHERE stmailbox.id NOT IN (SELECT id FROM USER_INFO)


    Let me know if there is a better way

    Thanks

Posting Permissions

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