Solved

SSRS Pass Multi-Value Parameter to Stored Procedure

Posted on 2014-11-28
5
342 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 500 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

726 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