Could two different databases in same Server sharing one SYMMETRIC KEY?

  • Hi Proz,

    I have two databases (DB1 & DB2) in same server. I had created symmetric key 'DB1Key' & certificate 'DB1Cert' to DB1 thus the encryption & decryption works fine at DB1.

    Now my problem is i try to open the key & use the certificate at DB2 but get this error: " Cannot find the symmetric key 'DB1Key', because it does not exist or you do not have permission."

    I need to decrypt the DB1's data at DB2. Example:-

    -- Database at DB2

    OPEN SYMMETRIC KEY DB1Key

    DECRYPTION BY CERTIFICATE DB1Cert;

    SELECT CONVERT(varchar(max),DecryptByKey(SCCode)) FROM DB1.dbo.Security_Code

    CLOSE SYMMETRIC KEY DB1Key

    Anyway to solve this problem? Thanks! 🙂

  • I believe the key is at the database level so is not available in another database. You would need to do it all in DB1. I;d create a procedure in DB1 that I call from DB2.

  • Thanks. That's what i did to temporarily solved the problem. Really don't have other ways to encounter this? Like copy the key & certificate to DB2?

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply