IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_g_allbranch_departtitle]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_g_allbranch_departtitle]
GO
CREATE procedure [dbo].[mps_g_allbranch_departtitle](
@cmpid int
)
as
begin
  -- 返回部门岗位
  set nocount on
  select distinct dp_dpstdid dp_id,dp_dpstdid , ot_id , dp_fullname+'/'+ot_title  dp_fullname ,dp_level , dp_order , ot_level,ot_order
    from mps_depart ,  mps_depart_title , mps_title
    where dp_cmpid=@cmpid and dp_bcid>0 and dt_dpid=dp_id and dt_otid=ot_id and dp_fullname>'' and ot_title>'' and dp_isdepart=0
    order by dp_level , dp_order , ot_level,ot_order
  set nocount off
end