• also, if your table variable has more than a few hundred rows, switching it to a temp table allows SQL to use automatically created statistics on that table in order to improve performance. change @secto_pat to #secto_pat, and wherever else it's created in your procedure.

    edit: just read that one of the tables is a view; that will create a crappy plan too, since the view is grabbing columns and creating joins that are probably not needed as far as this specific update.

    ; if you can update directly from the underlying tables, and eliminate unnecessary joins, that would speed this up too.

    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!