I have database A in this database there is a certificate and a table. I want to insert an encrypted value into a table which is in database A. The stored procedure is in database B and would ideally make a call like this:
EncryptByCert(Cert_ID('CertifiacteName'), 'SecretData')
This will always fail, because database B cannot find the certificate in database A
Without moving the stored procedure or the certificate, how can I create an encrypted value in database B using a certificate in database A?
You could wrap the EncryptByCert call in a function that lives in database A like this:
To insert data into your table in database A while connected to database B use something like this: