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?