IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_delete_weixin_subgroup]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_delete_weixin_subgroup]
GO

-- =============================================  
-- Author:  <Author,,Name>  
-- Create date: <Create Date,,>  
-- Description: <Description,,>  
-- =============================================  
CREATE PROCEDURE [dbo].[mps_delete_weixin_subgroup]  
 @mn_id int  
AS  
BEGIN  
 -- SET NOCOUNT ON added to prevent extra result sets from  
 -- interfering with SELECT statements.  
 declare @cmpid int  
 declare @roleid int  
 declare @groupid int  
 declare @headerid varchar(10)  
 SET NOCOUNT ON;  
  
 select @cmpid=mn_cmpid,@roleid=mn_roleid,@headerid=REPLACE(REPLACE(mn_flag,'title_s_sub',''),'title_r_sub',''),@groupid=mn_group  
 from mps_menu   
 where mn_id=@mn_id  
  
 delete from mps_menu where mn_cmpid=@cmpid and mn_roleid=@roleid and mn_flag  like '%_sub'+@headerid and mn_group=@groupid  
END