This essentially requires to follow below mentioned step:
- Verify SQL Server Master Key
- Create a Master Key Encryption password
- Create a self signed certificate
- A certificate is a digitally signed security object that contains a public (and optionally a private) key for SQL Server
- Create Symmetric Key.
- Encrypt the column(needs to be
varbinary
type)
To add records:
sample syntax:
OPEN SYMMETRIC KEY SymmetricKey1 DECRYPTION BY CERTIFICATE Certificate1;
-- Performs the update of the record
INSERT INTO dbo.test VALUES
(x, EncryptByKey(Key_GUID('SymmetricKey1'), CONVERT(varchar,'4545-58478-1245')));
GO
For step by step execution, follow this mssqltips article