IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_g_all_title]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_g_all_title]
GO
CREATE procedure [dbo].[mps_g_all_title](
@cmpid int 
)
as 
begin
-- 返回岗位
set nocount on
declare @tt1 table(otid int) 
insert into @tt1(otid) 
select distinct dt_otid 
from mps_depart_title , mps_depart 
where dp_cmpid=@cmpid and dt_dpid=dp_id 

select  ot_id , ot_title,ot_display 
from mps_title , @tt1 
where ot_id=otid and ot_title>'' and ot_display>'' 
order by ot_order 
set nocount off 
end