Decrypts data with an asymmetric key.
Applies to: SQL Server (SQL Server 2008 through current version).
The following example decrypts ciphertext that was encrypted with asymmetric key JanainaAsymKey02, which was stored in AdventureWorks2012.ProtectedData04. The returned data is decrypted using asymmetric key JanainaAsymKey02, which has been decrypted with password pGFD4bb925DGvbd2439587y. The plaintext is converted to type nvarchar.
SELECT CONVERT(nvarchar(max), DecryptByAsymKey( AsymKey_Id('JanainaAsymKey02'), ProtectedData, N'pGFD4bb925DGvbd2439587y' )) AS DecryptedData FROM [AdventureWorks2012].[Sales].[ProtectedData04] WHERE Description = N'encrypted by asym key''JanainaAsymKey02'''; GO