Gazareth (7/21/2014)
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
Thanks. I was not dropping the Key. I was only closing it and reopening it. 🙂
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/