microsoft / sqlmanagementobjects

Sql Management Objects, an API for scripting and managing SQL Server and Azure SQL Database
Other
132 stars 22 forks source link

Scripting Data Classifications of a Database #127

Closed aadhityai closed 8 months ago

aadhityai commented 1 year ago

Currently the scripts for Data Classification labels and information types are generated after initializing the column collection. Further there is no option to generate the Data Classification scripts exclusively for a database.

There can be an option to generate just the scripts for Data Classification say in a database level and can be achieved without needing to initialize the column collection.

A sample script can look like


USE [DemoDB]
GO

DROP SENSITIVITY CLASSIFICATION FROM [Person].[Password].[PasswordSalt]
GO

DROP SENSITIVITY CLASSIFICATION FROM [HumanResources].[Department].[DepartmentID]
GO

ADD SENSITIVITY CLASSIFICATION TO [HumanResources].[Department].[DepartmentID] WITH (label = 'Highly Confidential - GDPR', label_id = '<label_id>', information_type = 'National ID', information_type_id = '<info_type_id>', rank = High);
GO

ADD SENSITIVITY CLASSIFICATION TO [Person].[Password].[PasswordSalt] WITH (label = 'Confidential', label_id = '<label_id>', information_type = 'Credentials', information_type_id = '<info_type_id>');
GO
shueybubbles commented 8 months ago

Fixed in 170.17 and 161.48044