22,209
社区成员
发帖
与我相关
我的任务
分享
if isnull(@st1,'')<>''and ISNULL(@et1,'')<>''
begin
set @sql=@sql + ' and t.生效日期 between @st1 and @et1 '
end
if isnull(@st2,'')<>''and ISNULL(@et2,'')<>''
begin
set @sql=@sql + ' and t.失效日期 between @st2 and @et2 '
end
if ISNULL(@ischeck,'')<>''
begin
set @sql=@sql + ' and [是否审核]=@ischeck '
--set @sql=@sql + ' order by a.FBillNo '
end
if ISNULL(@FBillNo,'')<>''
begin
--set @sql=@sql + ' and t.FBillNo=@FBillNo'
set @sql=@sql + ' and t.FBillNo in ('+ '@FBillNo' + ')'
--set @sql=@sql + ' and t.FBillNo in (select c1 from [dbo].[split](@FBillNo,'')) '
end
print @sql
exec sp_executesql @sql
,N'@FBillNo NVARCHAR(50)
,@st1 date
,@et1 date
,@st2 date
,@et2 date
,@ischeck NVARCHAR(50)'
,@FBillNo
,@st1
,@et1
,@st2
,@et2
,@ischeck
set @sql=@sql + ' and t.FBillNo in (select c1 from [dbo].[split](@FBillNo,'','')) '
DECLARE @FBillNo VARCHAR(123)='1,2',@sql NVARCHAR(max)=''
SET @FBillNo=''''+REPLACE(@FBillNo,',',''',''')+''''
SET @sql=@sql + ' and t.FBillNo in ('+ @FBillNo + ')'
PRINT @sql
--生成格式
/*
and t.FBillNo in ('1','2')
*/