Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Reporting Services Development
 Multi-Valued Parameters

Author  Topic 

pmak
Starting Member

41 Posts

Posted - 2006-05-10 : 01:57:08
I am using 2005 SQL Reporting Services. I have a combo box with multi-valued parameters enabled on one of the report. The parameters is based on a query and the value of it is a "string" datatype and it will pass to a store procedure to retrieve a recordset for the report. I use the "IN" to accomondate multi-valued parameters. However I can get the store procedure work with more than a single parameter.

My store procedure

set ANSI_NULLS OFF
set QUOTED_IDENTIFIER OFF
GO
ALTER PROCEDURE [dbo].[rpt_Inventory_By_Location]
@Location nvarchar(255)

AS

SELECT Tbl_Product.Product,
Tbl_Inventory.StockNumber,
Tbl_Inventory.PotSize,
Tbl_Inventory_Detail.Location,
SUM(Tbl_Inventory_Detail.Quantity) AS SumOfQuantity,
Tbl_Inventory_Detail.UnitPrice,
Tbl_Inventory_Detail.Status,
Tbl_Inventory_Detail.UserNotes,
Tbl_Inventory_Detail.StockNumberNotes
FROM Tbl_Product
INNER JOIN Tbl_Inventory
ON Tbl_Product.ProductID = Tbl_Inventory.ProductID
INNER JOIN Tbl_Inventory_Detail
ON Tbl_Inventory.InventoryID = Tbl_Inventory_Detail.InventoryID
GROUP BY Tbl_Product.Product,
Tbl_Inventory.StockNumber,
Tbl_Inventory.PotSize,
Tbl_Inventory_Detail.Location,
Tbl_Inventory_Detail.UnitPrice,
Tbl_Inventory_Detail.Status,
Tbl_Inventory_Detail.UserNotes,
Tbl_Inventory_Detail.StockNumberNotes
HAVING (Tbl_Inventory_Detail.Location IN (@Location))
ORDER By Tbl_Product.Product

Hommer
Aged Yak Warrior

808 Posts

Posted - 2006-05-10 : 14:41:34
Make sure that string is single quoted and comma delimited, like 'Loc123','Loc234', because that is the IN should look like.
Go to Top of Page

mmarovic
Aged Yak Warrior

518 Posts

Posted - 2006-05-11 : 04:23:24
You can use dynamic sql and you should put the condition in where clause. Thare are also implementations not using dynamic sql. See: http://www.sql-server-performance.com/mm_list_random_values.asp
Go to Top of Page
   

- Advertisement -