IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_gen_order_label]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_gen_order_label]
GO
create proc [dbo].[mps_gen_order_label]
(
@cmpid int,
@bizid int
)
AS
declare @bqid varchar(max)
BEGIN
select @bqid=stuff((select ','+cast(bql_id as varchar) from mps_biztype_query bq with(nolock) where bq.bql_bizid=@bizid  for xml path('')),1,1,'')+',' 
declare @m int, @n int, @id varchar(20)
set @m = charindex(',',@bqid)
set @n = 1
while(@m > 0)
begin
  set @id=substring(@bqid,@n,@m-@n)
  set @n = @m + 1
  set @m = charindex(',',@bqid,@n)
  -- 得到 id
  if cast(@id as int) <> 0
  begin
  exec mps_gen_order_bizquery @cmpid,@bizid,@id
  exec mps_gen_order_bizquery_simple @cmpid,@bizid,@id
  end
end
END