IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_save_senior]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_save_senior]
GO
create procedure [dbo].[mps_save_senior] 
@bqlid int ,
@bizid int,
@biz_select nvarchar(4000),
@biz_from nvarchar(2000),
@biz_where nvarchar(4000),
@biz_orderby nvarchar(2000)
 as
begin
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
select @biz_select aaa
if exists(select 1 from mps_biztype_query_senior where bqls_bqlid=@bqlid and bqls_bizid=@bizid)
begin
  update mps_biztype_query_senior with(rowlock) set 
bqls_bizid  = case when @bizid=-999999999 then bqls_bizid else @bizid end ,
bqls_select   = case when  @biz_select='_none_' then bqls_select else @biz_select end ,
bqls_from   = case when  @biz_from='_none_' then bqls_from else @biz_from end ,
bqls_where  = case when  @biz_where='_none_' then bqls_where else @biz_where end ,
bqls_orderby  = case when  @biz_orderby='_none_' then bqls_orderby else @biz_orderby end 
  where bqls_bqlid=@bqlid and bqls_bizid=@bizid
end else
begin
insert into mps_biztype_query_senior(bqls_bqlid,
bqls_bizid,
bqls_select,
bqls_from,
bqls_where,
bqls_orderby) 
values(@bqlid,@bizid,@biz_select,@biz_from,@biz_where,@biz_orderby)
end
end