IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_g_depart_otlevel]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_g_depart_otlevel]
GO
 
create procedure [dbo].[mps_g_depart_otlevel](
@cmpid int ,
@mybcid int 
)
as 
begin
  -- 返回部门岗位
  set nocount on
  select distinct  dp_id, tg_grade , dp_fullname+'/'+tg_caption  dp_fullname ,dp_level , dp_order 
  from mps_depart ,  mps_title_grade
  where dp_cmpid=@cmpid and dp_bcid=@mybcid  and dp_fullname>'' and tg_caption>''  and dp_isdepart=0 
  order by dp_level , dp_order , tg_grade 
  set nocount off
end