Parameter/s in reports are used to filter data. Multi Value parameter is one that can accept more than one value.
Let's say if we would like to create report with RegionName Parameter that should be able to accept more than one Region value. Our T-SQL will use IN clause and small parenthesis around Parameter Name.
We can also write a Stored Procedure with Multi Value Parameter. To create multi value parameter, We need IN clause and each value in IN Clause should have (single quotes) around. When SSRS pass multiple values to parameter, it separate them by comma ( ,). We need to replace the comma with single quotes and comma as you can see in highlighted code. After that we can write our Dynamic SQL Query to use the value of Parameter.
Let's say if we would like to create report with RegionName Parameter that should be able to accept more than one Region value. Our T-SQL will use IN clause and small parenthesis around Parameter Name.
SELECT Col1Name ,Col2Name ,Col3Name FROM dbo.MyTableName WHERE Region IN (@RegionName)
We can also write a Stored Procedure with Multi Value Parameter. To create multi value parameter, We need IN clause and each value in IN Clause should have (single quotes) around. When SSRS pass multiple values to parameter, it separate them by comma ( ,). We need to replace the comma with single quotes and comma as you can see in highlighted code. After that we can write our Dynamic SQL Query to use the value of Parameter.
Create Procedure dbo.sp_TotalSale @Region VARCHAR(500) AS BEGIN Declare @var_Region VARCHAR(500) SET @var_Region=Replace(@Region,',',''',''') --print @var_Region Declare @SQL NVARCHAR(MAX) SET @SQL =' Select [SalePersonFName] ,[SalePersonLName] ,[ProductName] ,[ItemsSold] ,[SoldPrice] ,[SoldDate] ,[City] ,[State] ,[Country] ,[Region] into ##Temp from dbo.TotalSale where Region in ('''+@var_Region+''')' --Print @SQL Execute( @SQL ) Select * From ##Temp drop table ##Temp END Execute dbo.sp_TotalSale 'Asia,Europe'
Query for report with Single Value parameter, remember IsActive https://testmyspeed.onl/ is Bit type Column in table.
ReplyDeleteYes, as a Premium or Pro member of A Better Bid®, I have the advantage of inspecting vehicles in person at the Copart auction facility up to one hour before the live auction begins https://abetter.bid/locations/usa/pa/grantville-76. To arrange the preview, I simply contact the branch at (717) 861-7400 ahead of my visit. This service is incredibly valuable, as it allows me to assess the condition of the vehicles before placing my bids, ensuring I make informed decisions.
ReplyDelete