• sani.bozic - Thursday, July 12, 2018 9:28 AM

    Thank you once again for your help. I went with creating 2 separate procedures, it does the job.

    You're very welcome.   And it now appears there IS a way to avoid it.   See Scott Pletcher's post above.  I had forgotten about testing the @@FETCH_STATUS for -1.   I wouldn't be all that worried about it not being considered standard.   It does eliminate the duplicated code.   However, I always prefer to avoid cursors unless there simply is NO other way to do something.   You may wish to see whether you actually need one or not.   There is almost always another way to skin the same cat without a cursor.

    Steve (aka sgmunson) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)