Home Forums SQL Server 2005 Administering delete records from table2 that are not in table1 RE: delete records from table2 that are not in table1

  • Krasavita (3/17/2011)


    Hello, I need to delete records from table2 that are not in table1

    I have a table1 and table2

    table1

    DB, CODE, RATE, MAX(CONV_DATE) AS MaxConv_Date

    FROM table1

    table2

    DB, CODE, RATE, Date

    FROM

    table2

    I need to delete records from table2 that are not in table1

    Thank you

    EXCEPT will do a fine job on this. Have a look at it in Books Online.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)