I use this custom code to set a parameter called TermCodes in SSRS:
Public Function setTermDates (ByVal academicYear as String) as String
dim results as String
dim startYear as String = Mid(academicYear, 3, 2) 'Line 70
dim endYear as String = Mid(academicYear, 8, 2)
results = chr(39) & "FS" & startYear & chr(39) & ", " & chr(39) & "SS" & endYear & chr(39) & ", " & chr(39) & "US" & endYear & chr(39)
return results
End Function
The value of @TermCodes is 'FS13', 'SS14', 'US14'.
The SQL I'm trying to use this parameter with is:
select
min(StartDate1) FallStartDate,
min(EndDate1) FallEndDate,
min(StartDate2) SpringStartDate,
min(EndDate2) SpringEndDate,
min(StartDate3) SummerStartDate,
min(EndDate3) SummerEndDate
from (
select
Start_Date, End_Date,
'StartDate' + cast(row_number() over(order by Start_Date) as char(1)) StartDates,
'EndDate' + cast(row_number() over(order by Start_Date) as char(1)) EndDates
from Term
where Term_Code in (@TermCodes)
) t
pivot (
max(Start_Date)
for StartDates in(StartDate1,StartDate2,StartDate3)
) sd
pivot (
max(End_Date)
for EndDates in(EndDate1,EndDate2,EndDate3)
) ed
The problem is that the SQL is not returning anything. If I type this SQL into SQL Server Management Studio and replace the @TermCodes with the aforementioned value, it works. Why does it not work in SSRS?
Thanks!
Edit: I also have tried this to set my parameter with the same result:
Public Function setTermDates (ByVal academicYear as String) as String()
dim results(0 to 2) as String
dim startYear as String = Left(academicYear, 4)
dim endYear as String = Right(academicYear, 4)
results(0) = "FS" + startYear
results(1) = "SS" + endYear
results(2) = "US" + endYear
return results
End Function