Created
February 5, 2021 09:08
-
-
Save cocowalla/d1e8f82aa1cfe17caf7e814e1bbec448 to your computer and use it in GitHub Desktop.
Conditional SQL Server Data Classification
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE @compatibility_level TINYINT = 0; | |
SELECT @compatibility_level = compatibility_level FROM sys.databases WHERE name = 'MyDatabase'; | |
PRINT CONCAT('Database compatibility level is: ', @compatibility_level); | |
IF @compatibility_level < 150 | |
BEGIN | |
RAISERROR('Data Classification will not be performed, as database compatibility level %d is not high enough', 10, 1, @compatibility_level); | |
SET NOEXEC ON; | |
END; | |
GO | |
-- This will only be executed if database compatibility is >= 150 | |
ADD SENSITIVITY CLASSIFICATION TO | |
MyTable.Forename, | |
MyTable.Surname | |
WITH (LABEL='Confidential - GDPR', INFORMATION_TYPE='Name', RANK=MEDIUM); | |
SET NOEXEC OFF; | |
GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment