很简单地,我现在如果有一个报表,命令类型是Text,配置了几个报表参数,如果是以下这个形式就执行成功:
if(@TimeType=1)
begin
查询
end
else if (@TimeType = 2)
begin
查询
end
但是如果我在这前面加上一系列的判断+赋值,就像这样
if(@Year is not null and @quarter is not null)
begin
if(@quarter =1)
begin
set @startDate =convert(datetime, @Year+'-1-1')
set @EndDate=convert(datetime, @Year+'-3-31')
end
else if(@quarter =2)
begin
set @startDate =convert(datetime, @Year+'-4-1')
set @EndDate =convert(datetime, @Year+'-6-30')
end
else if(@quarter =3)
begin
set @startDate =convert(datetime, @Year+'-7-1')
set @EndDate =convert(datetime, @Year+'-9-30')
end
else if(@quarter =4)
begin
set @startDate =convert(datetime, @Year+'-10-1')
set @EndDate =convert(datetime, @Year+'-12-31')
end
else if(@quarter =5)
begin
set @startDate =convert(datetime, @Year+'-1-1')
set @EndDate =convert(datetime, @Year+'-6-30')
end
else if(@quarter =6)
begin
set @startDate =convert(datetime, @Year+'-7-1')
set @EndDate =convert(datetime, @Year+'-12-31')
end
else if(@quarter =7)
begin
set @startDate =convert(datetime, @Year+'-1-1')
set @EndDate =convert(datetime, @Year+'-12-31')
end
end
if(@TimeType=1)
begin
查询
end
else if (@TimeType = 2)
begin
查询
end
在预览的时候就会提示
“本地报表处理期间出错。处理报表时出错。XXX,必须声明标量变量@Year,必须声明标量变量@quarterxxxxxxxx”
让人非常想不明白,正常的T-SQL的话,怎么会前面加上几个判断就导致参数不生效呢?
添加回答
举报
0/150
提交
取消