Quantcast
Channel: SQL Server Reporting Services, Power View forum
Viewing all articles
Browse latest Browse all 10045

SSRS. Not passing fields/parameters to report when stored procedure keeps parameters inside IF statement

$
0
0

So what I mean:

I have stored procedure like this:

CREATEPROCEDURE sp_Example@param1 NVARCHAR(20)='',@param2 DATE =''ASBEGINIF(SELECT COUNT(*)FROM Table1 WHERE(Name =@param1 OR@param1 ='')AND(StartDate =@param2 OR@param2 =''))>2BEGINSELECT Name, Date, Price, EtcFROM Table2WHERE(Name =@param1 OR@param1 ='')AND(StartDate =@param2 OR@param2 ='')ENDIF(SELECT COUNT(*)FROM Table1 WHERE(Name =@param1 OR@param1 ='')AND(StartDate =@param2 OR@param2 =''))<2BEGINSELECT Name, Date, Price, EtcFROM Table3WHERE(Name =@param1 OR@param1 ='')AND(StartDate =@param2 OR@param2 ='')ENDEND

So in stored procedure are some input parameters and they are passed into IF statement.


If I use this stored procedure as report's dataset (Microsoft Visual Studio 2013) in following:

Add Dataset > Query Type: Stored Procedure > sp_Example It do NOT get any fields, but get parameters


If I use this stored procedure in following:

Add Dataset > Query Type: Text > EXECUTE sp_Example It get all required fields, but do NOT get parameters

Of course If I add manually parameters or fields It not working.


If I change IF statement in stored procedure something like:

IF(1<3)BEGINSELECT Name, Date, Price, EtcFROM Table3WHERE(Name =@param1 OR@param1 ='')AND(StartDate =@param2 OR@param2 ='')END

It normally working in report (getting all fields and parameters). So problem is that I pass parameters to IF statement. Have you any ideas how to pass parameters to IF statement and get It correctly working on report?


Viewing all articles
Browse latest Browse all 10045

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>