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

SSRS stored procedure with 2 IF conditions

$
0
0

Experts,

I have an SP that has 2 IF conditions, based on the condition i'll be calling a tablix in my SSRS report. For e.g.

Create Procedure SP1 AS @Param1 VARCHAR(50), @Param2 VARCHAR(50), @ViewBy BIT BEGIN IF (@ViewBy = 1) BEGIN IF (@Param1 = 'ABC') BEGIN SELECT.. FROM Table END END IF (@ViewBy = 0) BEGIN EXEC SP2 @Param1, @Param2 -- Calling this stored procedure inserts data in to one of the tables

SELECT Col1, Col2 FROM SomeTable END END

In my SSRS report, I have 2 datasets and tablixes, I have populated the 1st tablix with 5 columns coming from @ViewBy = 1 condition, in my 2nd tablix I only have 2 columns from @ViewBy = 0. The tablixes are looking fine and the data in the UI looks good too.

The problem I am running into is, if I run the report and from the dropdown I select "0" as value for ViewBy parameter, then my SP2 gets called and records get inserted. It works fine. HOWEVER, if I select "1" as value for ViewBy parameter dropdown, it's still calling the SP2 (even though SP2 gets called when @ViewBy = 0) and loading the data in the table which I DON'T want. Let me know what you guys suggest. I'd only want to get my tablix with 5 columns if I select @ViewBy = 1. Nothing should get inserted in my table.


Viewing all articles
Browse latest Browse all 10045

Trending Articles



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