• I'm no expert in this, but I think if you drop the key in the first query, then you won't be able to decrypt anything encrypted with it, so the second query returns null.

    I think someone may already have said this earlier in the thread.

    Create the key separately once, then only open & close it in your queries.

    Edit:

    Sorry, different tables etc. in the queries so that might not be the cause, although the point still stands.

    Can't see anything wrong in the query, what's it returning - NULLs, ******, error message?

    Thanks