EncryptByAsymKey (Transact-SQL)
SQL Server 2005
Updated:
14 April 2006
CREATE ASYMMETRIC KEY (Transact-SQL)
Encrypts data with an asymmetric key.
Transact-SQL Syntax Conventions
Encryption and decryption with an asymmetric key is very costly compared with encryption and decryption with a symmetric key. We recommend that you not encrypt large datasets, such as user data in tables, using an asymmetric key. Instead, you should encrypt the data using a strong symmetric key and encrypt the symmetric key using an asymmetric key.
The following example encrypts the text stored in @cleartext with the asymmetric key JanainaAsymKey02. The encrypted data is inserted into the ProtectedData04 table.
INSERT INTO [AdventureWorks].[Sales].[ProtectedData04]
values( N'data encrypted by asymmetric key ''JanainaAsymKey02''',
EncryptByAsymKey(AsymKey_ID('JanainaAsymKey02'), @cleartext) )
GO
Reference
DecryptByAsymKey (Transact-SQL)CREATE ASYMMETRIC KEY (Transact-SQL)