Renaming Policies, Conditions, and Categories

I have a habit of creating a new policy with only a vague idea of what I want to accomplish with it, and by the time I’m finished, the policy may have taken on a new tone. Other times, I make a test policy that turns out to be a great idea that I want to keep around. The problem with this? I start by naming the policy something terrible like TestPolicyDoThisThing. After making a few grouped expressions and half a dozen lines or more in the condition, I really don’t want to recreate it by using the GUI or script. I just want to rename the policy to something better, like RealPolicyDescriptiveName.

Renaming Policies is not easy or intuitive.

Right click on the policy, Rename…or not.

Rename Policy Missing

Where is Rename?

OK, click on the policy, then slowly click again to edit the name…

Why is there no interface for renaming a policy? I can click on a table to rename it, but not a policy? Explain to me how it is less dangerous to rename a table accidentally (by misclicking and typing something without paying attention) than to rename a policy. It isn’t. In fact, it’s much worse to randomly rename your tables. I hear that might break some applications.

So I poked around a bit. I really had no desire to recreate policies from scratch, and it absolutely should not be necessary. Luckily, there is a tsql command to rename a policy, and it’s fairly simple to use. SP_SysPolicy_Rename_Policy can rename a policy, just supply the @name parameter and the @new_name parameter.

Execution Failed

Wait! I know this exists!

It will help if you specify the correct database to use. Try executing the procedure with the fully qualified name, msdb.dbo.sp_syspolicy_rename_policy, and it will work successfully.

Execution Successful with FQN

Fully Qualified Names are best practice for a reason

Renaming Conditions works exactly the same way as policies when it comes to renaming them, Rename Condition is oddly absent, but a similarly named command will solve the problem. You can execute msdb.dbo.sp_syspolicy_rename_condition using the same parameters as the policy rename.

Missing Rename Condition

Renaming Categories is easy, strangely enough. There is a user interface for policy Categories. Click on Policy Management, then Manage Categories. This window will allow you to add new, and edit existing, categories. This is a great feature, and helps you keep track of Condition names. Ironically, it is also the feature I would use the least out of the renaming options.

Manage Categories Exists

So how did this sneak into the interface?

Edit Categories with Manage

Renaming and adding categories is as simple as typing in the Name field.

Summary As much as I like Policy Based Management, I wish that Microsoft would have finished building the feature – at least it feels like PBM is unfinished every time I work with it. So many facets are apparently missing, PowerShell execution is convoluted at best, and interface options are just strangely absent. Something as simple as renaming policies and conditions should not be available only through a hidden stored procedure. Policy Based Management is a great feature of SQL Server, and it’s one of the few standard edition features they have added lately. Why couldn’t Microsoft put a bit more effort into it and make it as powerful and easy to use as its potential implies?


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s