This function decrypts data with the private key of a certificate. Cryptographic transformations that use asymmetric keys consume significant resources. Therefore, EncryptByCert and DecryptByCert are not suited for routine encryption of user data.
The following example selects rows from [AdventureWorks2008R2].[ProtectedData04] that are marked as data encrypted by certificate JanainaCert02. The example decrypts the ciphertext with the private key of certificate JanainaCert02, which it first decrypts with the password of the certificate, pGFD4bb925DGvbd2439587y. The decrypted data is converted from varbinary to nvarchar.
SELECT convert(nvarchar(max), DecryptByCert(Cert_Id('JanainaCert02'),
= N'data encrypted by certificate '' JanainaCert02''';