Steps for encryption and decryption cell values in SQL Server.
Step 1: Create table and populate data.
Create a Master key(DMK-Database Master Key)
CREATE TABLE TestTable (Id INT, TextValue VARCHAR(50)) GO INSERT INTO TestTable (Id, TextValue) SELECT 1,'First' UNION ALL SELECT 2,'Second' UNION ALL SELECT 3,'Third' UNION ALL SELECT 4,'Fourth' UNION ALL SELECT 5,'Fifth' GO CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'Teciners#123' GO
The master key (DMK) in a database is encrypted by SQL server using its service master key (SMK).
SMK is created by a SQL Server instance when it starts up the very first time after installation. For any set of instances of SQL server, the SMK will always be different. So, the DMK in the database will be encrypted differently on each server.