• the cursor is your # 1 performanceproblem then.

    i'm sure you can replace it with a set based function:

    if you are doing the same logic to each row in the cursor, you can replace it.

    the only decent reason to use a cursor is if you are fiddling with metadata to build commands agaisnt tables and stuff,, or if you are feeding row results to a procedure (like sp_send_DbMail, for example)

    post it if you want to speed things up by a few orders of magnitude or more. i've seen things that took 12 hours replaced by a one second set based operation doing the same thing, which is what SQl server is all about...using SETS of data.

    i liken it to moving apples from one spot to another: a cursor moves the apples one by one, but the set based moves the BOX of apples;

    the time to move one apple is almost the same as moving the whole box...the more apples you were moving one by one, the more time you'd save.

    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!