How to Create and Evaluate Policies in SQL Server - MS SQL Server DBA Tutorial

In this video you will learn how to create and Evaluate Policy in SQL Server using SQL Server Management Studio as well as T-SQL script. It gives you overview of Policy management in SQL Server, you can use this video to setup a policy against SQL Server instance or instances as well as SQL Server objects such as databases, Logins, security and other policies that will keep your production environment intact with your checklist. You will learn how to evaluate on demand Policy as well as how to schedule policy using Policy management in SQL Server.

Script used in the video to Create Policy

DECLARE @object_set_id INT

EXEC msdb.dbo.Sp_syspolicy_add_object_set
  @object_set_id=@object_set_id OUTPUT

SELECT @object_set_id

DECLARE @target_set_id INT

EXEC msdb.dbo.Sp_syspolicy_add_target_set
  @target_set_id=@target_set_id OUTPUT

SELECT @target_set_id

EXEC msdb.dbo.Sp_syspolicy_add_target_set_level


DECLARE @policy_id INT

EXEC msdb.dbo.Sp_syspolicy_add_policy
  @description=N'Check compatibility of sql server 2014 databases',
  @policy_id=@policy_id OUTPUT,

SELECT @policy_id


Create and Evaluate Policies in SQL Server - SQL Server DBA Tutorial

No comments:

Post a Comment