I have one SSRS report which imports data from direct query.(I wrote similar to that down)
select a.[Ultimate Parent Account],b.[Account Internal ID],b.[Parent Account ],count(*) as Opportunities
from T_OPTYLINEVIEW_REP a
inner join T_OPTYVIEW_REP b on a.[Opportunity ID]=b.[Opportunity Internal ID]
where a.[Ultimate Parent Account] in (@Ultimate_Acct_ID)
group by a.[Ultimate Parent Account],b.[Account Internal ID],b.[Parent Account ]
Now if I want this to be stored procedure I did->
create procedure testing_proc(@ultimateaccount varchar(100))
as
select a.[Ultimate Parent Account],b.[Account Internal ID],b.[Parent Account ],count(*) as Opportunities
from T_OPTYLINEVIEW_REP a
inner join T_OPTYVIEW_REP b on a.[Opportunity ID]=b.[Opportunity Internal ID]
where a.[Ultimate Parent Account] IN (select * from STRING_SPLIT(@ultimateaccount, ','))
group by a.[Ultimate Parent Account],b.[Account Internal ID],b.[Parent Account ]
When I put this proc in SSRS it was acting weird like it was pulling few rows only when I selected 'all' in the parameter. Like it was pulling only 4 to 5 rows sometimes only 3 rows and all the time the rows were different.
But when I use the direct query and keep the parameter to select 'all' it pulls all the data which is around 9000 rows.
So why my proc is not working fine? I have used the STRING_SPLIT too if the problem is of commas in multiple selection.