I have a stored proc that has several parameters. Most of them allow for multiple selections in a drop-down menu. They are: vOwner, vFunction, vSite, vStatus (all multiple selections allowed and the “Select All” is also enabled), and then vStartDate and vEndDate.
For some reason, when I choose “Select All” for every parameter, SSRS cuts off some of the records. It seems to report everything except records for the very last “owner.” I’m looking for a clue as to why this might be happening. It happens when I select just one date’s worth of data. It’s as though that last owner isn’t even being picked up as part of the data set.
Where SSRS is concerned, the settings are fairly simple. I have a data set that references the stored procedure (below), and one for each of the lookup tables i have (function, status, etc.) Any help is appreciated. Let me know if other information is needed. Thanks!
Stored Procedure:
@vOwner varchar(1000) = NULL,
@vFunction varchar(1000) = NULL,
@vStatus varchar(1000) = NULL,
@vLocation varchar(1000) = NULL,
@vBeginDate datetime = NULL,
@vEndDate datetime = NULL
AS
BEGIN
--Allow for multiple owners, functions, etc. to be selected in SSRS.
Select @vOwner = ', ' + @vOwner + ', '
create table #Owner
(
Owner varchar(1000)
)
Insert Into #Owner
Select ManagerLastName + ', ' + ManagerFirstName As Owner
From Managers
Where @vOwner Like '%, ' + ManagerLastName + ', ' + ManagerFirstName + ', %'
Group By ManagerLastName, ManagerFirstName
--Function
Select @vFunction = ', ' + @vFunction + ', '
create table #Function
(
Functions varchar(1000)
)
Insert Into #Function
Select Functions
From Functions
Where @vFunction Like '%, ' + Functions + ', %'
Group By Functions
--Status
Select @vStatus = ', ' + @vStatus + ', '
create table #Status
(
IssueStatus varchar(1000)
)
Insert Into #Status
Select IssueStatus
From IssueStatus
Where @vStatus Like '%, ' + IssueStatus + ', %'
Group By IssueStatus
--Sites
Select @vLocation = ', ' + @vLocation + ', '
create table #Sites
(
siteName varchar(1000)
)
Insert Into #Sites
Select siteName
From Sites
Where @vLocation Like '%, ' + siteName + ', %'
Group By siteName
Select
recID,
siteName
functions
From issueInput
Where
@vFunction Like '%, ' + functions + ', %'
And @vOwner Like '%, ' + ManagerLastName + ', ' + ManagerFirstName + ', %'
And @vStatus Like '%, ' + IssueStatus + ', %'
And @vLocation Like '%, ' + SiteName + ', %'
And (@vBeginDate Is Null Or @vBeginDate = 0 Or @vBeginDate <= Cast(Convert(varchar,(OpenDate),101) As datetime))
And (@vEndDate Is Null Or @vEndDate = 0 Or @vEndDate >= Cast(Convert(varchar,(OpenDate),101) As datetime))
Order by OpenDate
END
Looks like it wasn’t a flaw in SSRS at all. After testing it out more in SSMS, I discovered that it was only the owner value that was being cut off at the end. I increased the @vOwner parameter from varchar(1000) to varchar(2000) and it is working fine now. I was simply passing too many characters into that parameter and it was getting truncated. Problem solved. Thanks to billinkc for that light bulb!