Try to do this
--> Create temtp table
CREATE TABLE #Test(MonthOfYear int, Year int, Account int,Name varchar(255))
INSERT INTO #Test
VALUES(1,2013,1,'A')
INSERT INTO #Test
VALUES(12,2012,4,'B')
INSERT INTO #Test
VALUES(1,2013,4,'C')
INSERT INTO #Test
VALUES(1,2012,1,'D')
INSERT INTO #Test
VALUES(1,2013,5,'E')
--Build dynamic sql
DECLARE @Month int, @Year int, @account varchar(255)
,@sql varchar(1000)
,@DBName varchar(100) ='TEST'
-->Search single value in @account
SELECT @Month = 1, @Year = 2013, @account ='1'
SET @sql = '
SELECT MonthOfYear, Year, Account,Name
FROM #Test
WHERE MonthOfYear ='+CONVERT(varchar(2),@Month)
+' AND Year = '+CONVERT(varchar(5),@Year)
+' AND Account IN('+@Account+')'
PRINT @sql
EXEC ('USE '+@DBName+ @sql)
--> Search mutilple values in @account
SELECT @Month = 1, @Year = 2013, @account ='1,4'
SET @sql = '
SELECT MonthOfYear, Year, Account,Name
FROM #Test
WHERE MonthOfYear ='+CONVERT(varchar(2),@Month)
+' AND Year = '+CONVERT(varchar(5),@Year)
+' AND Account IN('+@Account+')'
PRINT @sql
EXEC ('USE '+@DBName+ @sql)
DROP TABLE #Test
Both yours and my script works fine in SSMS (with single and multi-value), and mine also works in SSRS if I select a single value. The issue is when I select multi-value in SSRS. My report parameter properties for @acct are as follow:
data type = string
multi-value checked
allow blank value checkd
available values: non-queried
default values: Null