IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_g_1depart_title]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_g_1depart_title]
GO
create procedure [dbo].[mps_g_1depart_title](  
@cmpid int ,  
@mydpid int   
) as  
begin  
 set nocount on  
 declare @tt table(otid int)   
 insert into @tt(otid)   
 select distinct dt_otid   
 from  mps_depart_title , mps_depart   
 where dp_cmpid=@cmpid and dp_id=@mydpid and dt_dpid=dp_id  
   
 select  ot_id , ot_title,ot_display   
 from mps_title , @tt   
 where ot_id=otid and ot_title>'' and ot_display>''   
 order by ot_order   
 set nocount off  
end