• AhTu_SQL2k+ - Thursday, March 14, 2019 9:08 PM

    Hi Steve,
    I feel your frustration on my previous question, I apologize for that. English is my second language and perhaps I didn't describe the question clearly in my post. What I am curiously to find out is why after I added the option "WITH ENCRYPTION" to the fast working script (1 second ) will cause it halted (keep querying for hours). I was trying to point out where the option is added by the sample only, not to seek for help to rectify the script.

    I'd already validated that your syntax wasn't the problem.   However, with no idea what the function does or the code within, we've got zero chance at helping.   Although there are a couple of things to try.   Force the object to be recompiled by running sp_recompile on it.  Then capture an execution plan when you run it with encryption, and again when you run it without.   Look at the differences.   It might tell you something.   However, without either of those execution plans, we're probably going to be left guessing.

    EDIT:  Be sure to recompile between executions, so you are starting at a known point each time.

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