Creating a master key in SQL Server

I am trying to inject an encrypted column, as in the following MSDN example. I understand most of the code except for the very first line:

--If there is no master key, create one now. IF NOT EXISTS (SELECT * FROM sys.symmetric_keys WHERE symmetric_key_id = 101) 

When I run this in the AdventureWorks database on my local computer, the key already exists, and that's fine; I got an example to work fine and encrypt / decrypt on my machine. However, this code does not mention a symmetric_key_id of 101 any at any point.

Is 101 reserved identifier for symmetric keys?

+4
source share
1 answer

As seen HERE , symmetric_key_id 101 is the id for the Database Master Key .

The number of primary database keys is limited only by the number of databases you have - you can have one master key for each database, and its identifier is 101.

+4
source

Source: https://habr.com/ru/post/1391478/


All Articles