IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_g_source_info]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_g_source_info]
GO
 
CREATE procedure [dbo].[mps_g_source_info](
  @cmpid int ,
  @biztype varchar(30),
  @bizid int,
  @sourcename nvarchar(50) 
) as
begin
set nocount on
declare @flag int 
declare @tag int 
set @flag = @bizid/100000000
if (@flag=1 or @flag=2 or @flag=3 or @flag=4 or @flag=11 or @flag=12 or @flag=13 or @flag=14) 
begin
set @tag = @bizid - @flag * 100000000 
end else 
begin
  set @tag = @bizid - @flag * 100000000 
  if (@biztype='cst') 
  begin
  select top 1 @tag = ct_tag from mps_csttype where ct_id=@tag 
  end else 
  if (@biztype='prd') 
  begin
  select top 1 @tag = pc_tag from mps_prdctg where pc_id=@tag 
  end else 
  if (@biztype='equ') 
  begin
  select top 1 @tag = ec_tag from mps_equctg where ec_id=@tag 
  end else 
  if (@biztype='etc') 
  begin
  select top 1 @tag = etc_tag from mps_ext_resource where etc_id=@tag 
  end 
end 
  
select * from mps_fieldinfo where fldi_tbtype=@biztype and fldi_tbid=@tag and fldi_hidden=1 and fldi_system=1 order by fldi_fieldname  
select * from mps_biztype_source where bizs_type=@biztype  and  bizs_bizid=@tag and bizs_source=@sourcename 
set nocount off
end