IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_delete_prdctg1]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_delete_prdctg1]
GO
create proc mps_delete_prdctg1
@cmpid int,
@mypcid bigint
as
begin
set nocount on

if( exists (select pc_id from mps_prdctg where pc_father = @mypcid))
begin
select 'error' error, '此分类存在子分类' errorinfo
return 
end

if( exists (select prd_id from mps_prd where prd_pcid = @mypcid))
begin
select 'error' error, '此分类存在产品' errorinfo
return 
end

delete from mps_prdctg where pc_cmpid = @cmpid and pc_id = @mypcid

set nocount off 
end