IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_add_query]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_add_query]
GO
create proc [dbo].[mps_add_query]
@cmpid int,
@bizid int,
@useruid int,
@bqid nvarchar(max)
AS
BEGIN
--选中查询标签
declare @m int, @n int, @id varchar(20)
set @m = charindex(',',@bqid)
set @n = 1
delete from mps_biztype_query_users where bqlu_cuid=@useruid and bqlu_bizid=@bizid
while(@m > 0)
begin
  set @id=substring(@bqid,@n,@m-@n)
  set @n = @m + 1
  set @m = charindex(',',@bqid,@n)
  exec mps_gen_order_bizquery @cmpid,@bizid,@id
  exec mps_gen_order_bizquery_simple @cmpid,@bizid,@id
  insert into mps_biztype_query_users values(@id,@useruid,@bizid)
end
END