IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_delete_program]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_delete_program]
GO
CREATE procedure [dbo].[mps_delete_program] 
@cmpid int ,
@ptid int
as
begin
set nocount on
   if (exists (select * from mps_programtype where pt_cmpid=@cmpid and pt_fid=@ptid)) 
   begin
   select 1 resultvalue , '该目录下有程序，无法删除' resultmessage 
   end  else 
   begin
   delete mps_programtype where pt_cmpid=@cmpid and pt_id=@ptid 
   select 0 resultvalue , '删除成功' resultmessage 
   end 
   set nocount off 
end