IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_g_1branch_depart]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_g_1branch_depart]
GO
CREATE procedure [dbo].[mps_g_1branch_depart](
@cmpid int,
@mybcid int,
@key nvarchar(255)
)
as 
begin
-- 返回部门名称
set nocount on
if(@key = '_none_' or @key = '') set @key = ''
else set @key = '%'+@key+'%'

select top 400 dp_id ,dp_dpstdid, dp_depart,dp_fullname ,dp_code ,dp_display 
from mps_depart 
where dp_cmpid=@cmpid and dp_bcid=@mybcid and dp_fullname>'' and dp_depart>''  and dp_isdepart=0 
  and (@key = '' or dp_depart like @key)
order by  dp_order ,dp_level
set nocount off
end