• this is typically how i do it.

    1. do a full backup, just in case.

    2. SELECT the rows that in theory, should be affected...we might get a specific row count out of this, which we want our update to match:

    SELECT *

    FROM dbo.tabletoupdate MyTargetTable

    LEFT OUTER JOIN ExcelDataSource...sheet1$ MyExcel

    ON MyTargetTable.ItemID = MyExcel.ItemID

    WHERE MyTargetTable.WHAREHOUSE <> MyExcel.WHAREHOUSE

    3. create an explicit transaction with teh update statement , and let it run:

    SET XACT_ABORT ON

    BEGIN TRAN

    --much more explicit, only change rows that are different

    UPDATE MyTargetTable

    SET WHAREHOUSE = MyExcel.WHAREHOUSE

    --SELECT *

    FROM dbo.tabletoupdate MyTargetTable

    LEFT OUTER JOIN ExcelDataSource...sheet1$ MyExcel

    ON MyTargetTable.ItemID = MyExcel.ItemID

    WHERE MyTargetTable.WHAREHOUSE <> MyExcel.WHAREHOUSE

    --ROLLBACK TRAN

    --COMMIT TRAN

    4. IMPORTANT Note the above has both COMMIT TRAN and ROLLBACK TRAN COMMENTED OUT! the table's going to be locked untill you are done reviewing and you either commit or rollback!

    5. Review the data in general, mae sure it looks good.

    SELECT *

    FROM dbo.tabletoupdate MyTargetTable

    LEFT OUTER JOIN ExcelDataSource...sheet1$ MyExcel

    ON MyTargetTable.ItemID = MyExcel.ItemID

    6. lets go ahead and commit, if it's good.

    COMMIT TRAN

    7. IF it was bad, just ROLLBACK the transaction and start fresh.

    ROLLBACK TRAN

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!