I'm using Reporting Services to show some data from a dataset in SQL Server, which has two parameters. Now, if the button 'View Report' isn't clicked, the data won't show on page load (Preview tab in Visual Studio / Web Browsing at localhost). What can I do that on page load, the data would show nonetheless if parameters are filled or not?
I have tried changing SQL code to include IF
conditionals so that if parameters are null, select all the data, ELSE
, display data by parameters but this didn't work, it seems like the query of data set is executed only when clicking the 'View Report' button.
Currently, I am using this SQL code which works fine when searching with filled parameters and clicking the aforementioned button:
IF(@SearchName IS NULL OR @SearchName = '')
SELECT * FROM dbo.person;
ELSE
SELECT * FROM dbo.person WHERE ((name LIKE '%' + @SearchName + '%') OR (surname LIKE '%' + @SearchSurname+ '%'));
The expected outcome is returning all the data set (SELECT * FROM dbo.person
)
unless the parameter is filled and the button is clicked.