Welcome to MSSQL Forum!
MSSQL Forum - Discussions about Microsoft SQL Server

You are currently viewing our community forums as a guest user. Sign up or
Having an account grants you additional privileges, such as creating and participating in discussions.

Renaming a policy

Discussion in 'Installation and Administration' started by Peter Schmitz, Oct 1, 2012.

  1. Peter Schmitz

    Peter Schmitz Administrator Staff Member

    Today, I needed to rename a policy in SQL Server Management Studio (SSMS). However, it is not possible to do so using the GUI for some reason.

    The usual tricks to rename objects (highlighting the object and pressing F2, or right-clicking the object and selecting "Rename" from the drop-down menu) did not work, so I was about to just delete and recreate the policy.

    Before doing so, though, I figured I would try and spend a few minutes to see if there was an easier way to accomplish the goal. And as it turns out, there is.

    The names of the policies are stored in the msdb database, particularly in the dbo.syspolicy_policies_internal table. To rename the policy, use the following query:

    Code (Tsql):

    UPDATE
        msdb.dbo.syspolicy_policies_internal
    SET name = '<new name>'
    WHERE name = '<old name>'
     
    Obviously, replace <new name> and <old name> with your own values.

Share This Page

Sponsored link: