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.
| Author |
Topic |
|
latingntlman
Yak Posting Veteran
96 Posts |
Posted - 2008-11-21 : 15:21:47
|
| I'm passing three parameters in a sproc to a SSRS 2005 report. Two datetime fields (@FromDate, @ToDate) and an integer field (@CustNo). The intent is for a user to have the option of running the report by selecting a date range or by entery one or more Customer#'s. My challenge is for the @CustNo to be accepted in the report in a way that the user can enter more than one CustNo if they need to. i.e. Enter CustomerNo: 123456, 153222, 943382Below is my code. I'm wondering if there's something that I need to do at the report side.CREATE PROCEDURE prCustomerOrders@startDate DATETIME,@endDate DATETIME,@CustNo INTASSELECTc.CustomerID,c.CompanyName,c.City,c.ContactName,o.OrderID,o.OrderDate,od.UnitPrice,od.Quantity,od.UnitPrice * od.Quantity AS ExtendedPriceFROMCustomers cINNER JOIN Orders o ON c.CustomerID = o.CustomerIDINNER JOIN OrderDetails od ON o.OrderID = od.OrderIDWHEREo.OrderDate BETWEEN @startDate AND @endDateOr c.CustomerID in (@CustNo)ORDER BYc.CompanyName,o.OrderDate |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-22 : 00:32:30
|
quote: Originally posted by latingntlman I'm passing three parameters in a sproc to a SSRS 2005 report. Two datetime fields (@FromDate, @ToDate) and an integer field (@CustNo). The intent is for a user to have the option of running the report by selecting a date range or by entery one or more Customer#'s. My challenge is for the @CustNo to be accepted in the report in a way that the user can enter more than one CustNo if they need to. i.e. Enter CustomerNo: 123456, 153222, 943382Below is my code. I'm wondering if there's something that I need to do at the report side.CREATE PROCEDURE prCustomerOrders@startDate DATETIME,@endDate DATETIME,@CustNo INTASSELECTc.CustomerID,c.CompanyName,c.City,c.ContactName,o.OrderID,o.OrderDate,od.UnitPrice,od.Quantity,od.UnitPrice * od.Quantity AS ExtendedPriceFROMCustomers cINNER JOIN Orders o ON c.CustomerID = o.CustomerIDINNER JOIN OrderDetails od ON o.OrderID = od.OrderIDWHEREo.OrderDate BETWEEN @startDate AND @endDateOr ','+@CustNo + ',' LIKE '%,'+CAST(c.CustomerID AS varchar(10)) + ',%' ORDER BYc.CompanyName,o.OrderDate
modify like above. Also i belive it should be AND and not OR as it has satisfy both date condition and numbers. |
 |
|
|
|
|
|
|
|