?
Solved

SSRS Pass Multi-Value Parameter to Stored Procedure

Posted on 2014-11-28
5
Medium Priority
?
349 Views
Last Modified: 2014-11-29
I was able to get some help with passing multi-value parameters from an SSRS report to a SP several months back, but now I have a follow up.

@StoreID is working fine but @GroupName gives me the following error 'Conversion failed when converting the varchar value 'Redemption' to data type int'

I'm using the same function for both and have never had any issues with other SP. I'm must be doing something wrong with the @GroupName.

ALTER PROCEDURE [dbo].[sp_GameScoring]

@BeginDate DateTime
,@EndDate DateTime
,@StoreID  varchar (1000)
, @GroupName varchar (1000)


AS




WITH GrossCollectedRank AS
	(
SELECT			ROW_NUMBER() OVER (ORDER BY SUM(GrossCollected)DESC) AS GrossCollectedRank
				, StoreID
				, StoreGameID
				, SUM(GrossCollected) AS GrossCollected
				,(CASE
						WHEN (SUM(CreditPlays) + SUM(BonusPlays) + SUM(CourtesyPlays)) = 0 
						THEN (GamePrice) 
						ELSE SUM(MoneyIN) /(SUM(CreditPlays) + SUM(BonusPlays) + SUM(CourtesyPlays)) 
						END) AS AvgPrice
				, Sum(Tickets) / Sum(GrossCollected) / 100 AS Payout

FROM            View_GrossGameSalesDetail

WHERE			StoreID IN (SELECT CAST(value as int) from dbo.ParmsToList(@StoreID,','))
				AND GroupName IN (SELECT CAST(value as int) from dbo.ParmsToList(@GroupName,','))
				AND (TransactionDate BETWEEN @BeginDate AND @EndDate)

GROUP BY		StoreID, StoreGameID, GamePrice
)
	


	SELECT	SM.StoreID
			, SM.StoreGameID
			, SM.GroupName
			, SM. MachineName
			, SM.ActiveDate
			, GC.GrossCollected
			, GC.GrossCollectedRank
			, GC.AvgPrice
			, GC.Payout

			
	FROM StoreMasterGameList SM
			JOIN GrossCollectedRank GC ON SM.StoreID = GC.StoreID and SM.StoreGameID = GC.StoreGameID
			

Open in new window

0
Comment
Question by:dk04
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 11

Expert Comment

by:John_Vidmar
ID: 40470987
Line 30, below, is attempting to convert each element in the comma-delimited list contained in @GroupName into integer values.  Instead of a number, I suspect @GroupName contains the value Redemption.
AND GroupName IN (SELECT CAST(value as int) from dbo.ParmsToList(@GroupName,','))

Open in new window

0
 

Author Comment

by:dk04
ID: 40470990
Yes it does. It is one of the groups to choose from. In the table it is a varchar (100)
0
 
LVL 11

Accepted Solution

by:
John_Vidmar earned 2000 total points
ID: 40471644
Cool, so instead of attempting to convert to int, convert to varchar(100):
AND GroupName IN (SELECT CAST(value as varchar(100)) from dbo.ParmsToList(@GroupName,','))

Open in new window

0
 

Author Comment

by:dk04
ID: 40471702
It worked. Awesome! Thanks
0
 

Author Closing Comment

by:dk04
ID: 40471703
Perfect, just what I needed.
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how the fundamental information of how to create a table.
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question