Why SP_Naming policy still blocked my correct creating?












0















I used PBM to manage my policy against my user DBs.
The Condition is:



Declare @condition_id int
EXEC msdb.dbo.sp_syspolicy_add_condition @name=N'SP_Naming_convention', @description=N'', @facet=N'StoredProcedure', @expression=N'<Operator>
<TypeClass>Bool</TypeClass>
<OpType>LIKE</OpType>
<Count>2</Count>
<Attribute>
<TypeClass>String</TypeClass>
<Name>Name</Name>
</Attribute>
<Constant>
<TypeClass>String</TypeClass>
<ObjType>System.String</ObjType>
<Value>usp_%</Value>
</Constant>
</Operator>', @is_name_condition=2, @obj_name=N'usp_%', @condition_id=@condition_id OUTPUT
Select @condition_id

GO


The policy is:



Declare @object_set_id int
EXEC msdb.dbo.sp_syspolicy_add_object_set @object_set_name=N'SP_Naming_ObjectSet', @facet=N'StoredProcedure', @object_set_id=@object_set_id OUTPUT
Select @object_set_id

Declare @target_set_id int
EXEC msdb.dbo.sp_syspolicy_add_target_set @object_set_name=N'SP_Naming_ObjectSet', @type_skeleton=N'Server/Database/StoredProcedure', @type=N'PROCEDURE', @enabled=True, @target_set_id=@target_set_id OUTPUT
Select @target_set_id

EXEC msdb.dbo.sp_syspolicy_add_target_set_level @target_set_id=@target_set_id, @type_skeleton=N'Server/Database/StoredProcedure', @level_name=N'StoredProcedure', @condition_name=N'', @target_set_level_id=0
EXEC msdb.dbo.sp_syspolicy_add_target_set_level @target_set_id=@target_set_id, @type_skeleton=N'Server/Database', @level_name=N'Database', @condition_name=N'', @target_set_level_id=0


GO

Declare @policy_id int
EXEC msdb.dbo.sp_syspolicy_add_policy @name=N'SP_Naming', @condition_name=N'SP_Naming_convention', @policy_category=N'', @description=N'Get out of my box you DEV!', @help_text=N'Stop doing this!', @help_link=N'', @schedule_uid=N'00000000-0000-0000-0000-000000000000', @execution_mode=1, @is_enabled=True, @policy_id=@policy_id OUTPUT, @root_condition_name=N'', @object_set=N'SP_Naming_ObjectSet'
Select @policy_id


GO


I tried to create an SP named usp_whatever:



create proc usp_whatever
as
begin
select @@VERSION
end


But the policy still blocked mine...
Any thought? Thanks,









share



























    0















    I used PBM to manage my policy against my user DBs.
    The Condition is:



    Declare @condition_id int
    EXEC msdb.dbo.sp_syspolicy_add_condition @name=N'SP_Naming_convention', @description=N'', @facet=N'StoredProcedure', @expression=N'<Operator>
    <TypeClass>Bool</TypeClass>
    <OpType>LIKE</OpType>
    <Count>2</Count>
    <Attribute>
    <TypeClass>String</TypeClass>
    <Name>Name</Name>
    </Attribute>
    <Constant>
    <TypeClass>String</TypeClass>
    <ObjType>System.String</ObjType>
    <Value>usp_%</Value>
    </Constant>
    </Operator>', @is_name_condition=2, @obj_name=N'usp_%', @condition_id=@condition_id OUTPUT
    Select @condition_id

    GO


    The policy is:



    Declare @object_set_id int
    EXEC msdb.dbo.sp_syspolicy_add_object_set @object_set_name=N'SP_Naming_ObjectSet', @facet=N'StoredProcedure', @object_set_id=@object_set_id OUTPUT
    Select @object_set_id

    Declare @target_set_id int
    EXEC msdb.dbo.sp_syspolicy_add_target_set @object_set_name=N'SP_Naming_ObjectSet', @type_skeleton=N'Server/Database/StoredProcedure', @type=N'PROCEDURE', @enabled=True, @target_set_id=@target_set_id OUTPUT
    Select @target_set_id

    EXEC msdb.dbo.sp_syspolicy_add_target_set_level @target_set_id=@target_set_id, @type_skeleton=N'Server/Database/StoredProcedure', @level_name=N'StoredProcedure', @condition_name=N'', @target_set_level_id=0
    EXEC msdb.dbo.sp_syspolicy_add_target_set_level @target_set_id=@target_set_id, @type_skeleton=N'Server/Database', @level_name=N'Database', @condition_name=N'', @target_set_level_id=0


    GO

    Declare @policy_id int
    EXEC msdb.dbo.sp_syspolicy_add_policy @name=N'SP_Naming', @condition_name=N'SP_Naming_convention', @policy_category=N'', @description=N'Get out of my box you DEV!', @help_text=N'Stop doing this!', @help_link=N'', @schedule_uid=N'00000000-0000-0000-0000-000000000000', @execution_mode=1, @is_enabled=True, @policy_id=@policy_id OUTPUT, @root_condition_name=N'', @object_set=N'SP_Naming_ObjectSet'
    Select @policy_id


    GO


    I tried to create an SP named usp_whatever:



    create proc usp_whatever
    as
    begin
    select @@VERSION
    end


    But the policy still blocked mine...
    Any thought? Thanks,









    share

























      0












      0








      0








      I used PBM to manage my policy against my user DBs.
      The Condition is:



      Declare @condition_id int
      EXEC msdb.dbo.sp_syspolicy_add_condition @name=N'SP_Naming_convention', @description=N'', @facet=N'StoredProcedure', @expression=N'<Operator>
      <TypeClass>Bool</TypeClass>
      <OpType>LIKE</OpType>
      <Count>2</Count>
      <Attribute>
      <TypeClass>String</TypeClass>
      <Name>Name</Name>
      </Attribute>
      <Constant>
      <TypeClass>String</TypeClass>
      <ObjType>System.String</ObjType>
      <Value>usp_%</Value>
      </Constant>
      </Operator>', @is_name_condition=2, @obj_name=N'usp_%', @condition_id=@condition_id OUTPUT
      Select @condition_id

      GO


      The policy is:



      Declare @object_set_id int
      EXEC msdb.dbo.sp_syspolicy_add_object_set @object_set_name=N'SP_Naming_ObjectSet', @facet=N'StoredProcedure', @object_set_id=@object_set_id OUTPUT
      Select @object_set_id

      Declare @target_set_id int
      EXEC msdb.dbo.sp_syspolicy_add_target_set @object_set_name=N'SP_Naming_ObjectSet', @type_skeleton=N'Server/Database/StoredProcedure', @type=N'PROCEDURE', @enabled=True, @target_set_id=@target_set_id OUTPUT
      Select @target_set_id

      EXEC msdb.dbo.sp_syspolicy_add_target_set_level @target_set_id=@target_set_id, @type_skeleton=N'Server/Database/StoredProcedure', @level_name=N'StoredProcedure', @condition_name=N'', @target_set_level_id=0
      EXEC msdb.dbo.sp_syspolicy_add_target_set_level @target_set_id=@target_set_id, @type_skeleton=N'Server/Database', @level_name=N'Database', @condition_name=N'', @target_set_level_id=0


      GO

      Declare @policy_id int
      EXEC msdb.dbo.sp_syspolicy_add_policy @name=N'SP_Naming', @condition_name=N'SP_Naming_convention', @policy_category=N'', @description=N'Get out of my box you DEV!', @help_text=N'Stop doing this!', @help_link=N'', @schedule_uid=N'00000000-0000-0000-0000-000000000000', @execution_mode=1, @is_enabled=True, @policy_id=@policy_id OUTPUT, @root_condition_name=N'', @object_set=N'SP_Naming_ObjectSet'
      Select @policy_id


      GO


      I tried to create an SP named usp_whatever:



      create proc usp_whatever
      as
      begin
      select @@VERSION
      end


      But the policy still blocked mine...
      Any thought? Thanks,









      share














      I used PBM to manage my policy against my user DBs.
      The Condition is:



      Declare @condition_id int
      EXEC msdb.dbo.sp_syspolicy_add_condition @name=N'SP_Naming_convention', @description=N'', @facet=N'StoredProcedure', @expression=N'<Operator>
      <TypeClass>Bool</TypeClass>
      <OpType>LIKE</OpType>
      <Count>2</Count>
      <Attribute>
      <TypeClass>String</TypeClass>
      <Name>Name</Name>
      </Attribute>
      <Constant>
      <TypeClass>String</TypeClass>
      <ObjType>System.String</ObjType>
      <Value>usp_%</Value>
      </Constant>
      </Operator>', @is_name_condition=2, @obj_name=N'usp_%', @condition_id=@condition_id OUTPUT
      Select @condition_id

      GO


      The policy is:



      Declare @object_set_id int
      EXEC msdb.dbo.sp_syspolicy_add_object_set @object_set_name=N'SP_Naming_ObjectSet', @facet=N'StoredProcedure', @object_set_id=@object_set_id OUTPUT
      Select @object_set_id

      Declare @target_set_id int
      EXEC msdb.dbo.sp_syspolicy_add_target_set @object_set_name=N'SP_Naming_ObjectSet', @type_skeleton=N'Server/Database/StoredProcedure', @type=N'PROCEDURE', @enabled=True, @target_set_id=@target_set_id OUTPUT
      Select @target_set_id

      EXEC msdb.dbo.sp_syspolicy_add_target_set_level @target_set_id=@target_set_id, @type_skeleton=N'Server/Database/StoredProcedure', @level_name=N'StoredProcedure', @condition_name=N'', @target_set_level_id=0
      EXEC msdb.dbo.sp_syspolicy_add_target_set_level @target_set_id=@target_set_id, @type_skeleton=N'Server/Database', @level_name=N'Database', @condition_name=N'', @target_set_level_id=0


      GO

      Declare @policy_id int
      EXEC msdb.dbo.sp_syspolicy_add_policy @name=N'SP_Naming', @condition_name=N'SP_Naming_convention', @policy_category=N'', @description=N'Get out of my box you DEV!', @help_text=N'Stop doing this!', @help_link=N'', @schedule_uid=N'00000000-0000-0000-0000-000000000000', @execution_mode=1, @is_enabled=True, @policy_id=@policy_id OUTPUT, @root_condition_name=N'', @object_set=N'SP_Naming_ObjectSet'
      Select @policy_id


      GO


      I tried to create an SP named usp_whatever:



      create proc usp_whatever
      as
      begin
      select @@VERSION
      end


      But the policy still blocked mine...
      Any thought? Thanks,







      sql-server policy-based-management





      share












      share










      share



      share










      asked 5 mins ago









      DBALUKE HUANGDBALUKE HUANG

      496




      496






















          0






          active

          oldest

          votes











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "182"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f232937%2fwhy-sp-naming-policy-still-blocked-my-correct-creating%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Database Administrators Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f232937%2fwhy-sp-naming-policy-still-blocked-my-correct-creating%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          SQL Server 17 - Attemping to backup to remote NAS but Access is denied

          Always On Availability groups resolving state after failover - Remote harden of transaction...

          Restoring from pg_dump with foreign key constraints