Login    
 
 
 
 
Text/HTML
  
You are here :: Blogs Saturday, May 19, 2012

Search
Note: This uses the internal blog search engine. The Google search engine is also available at the top of the page.
  
Disclaimer

Please review the site disclaimer before downloading or using content found on this site

  
Categories
  
DEVSHED Blog
As always, I welcome your comments!
Apr 21

Written by: Steve Gray
4/21/2010 4:15 PM  RssIcon

In SSRS, there is a limitation that you cannot pass a multivalue parameter to a stored procedure. I read a couple of ways to get around that, the best being this one from Mark Vaillancourt. The ‘Scooby Do’ references are pretty funny. Ruh roh.

http://markvsql.com/index.php/2010/01/jinkies-passing-multivalue-ssrs-parameters-to-stored-procedures

In the spirit of laziness, I wanted a slightly simpler answer. I prompt the use to enter a comma separated list of customers, and parse them into a table in SQL. Then, I join that table to the customer master table in my application. Or you could do a ‘WHERE CUSTNMBR IN (SELECT CUSTNMBR FROM @MYTABLE)’

 

Code Snippet
  1. declare @customerNumber varchar(100)
  2. declare @customers table (custnmbr varchar(15))
  3. declare @customer varchar(15)
  4. declare @pos int
  5.  
  6. set @customerNumber = '1234,qwer,zxv'
  7. set @pos = CHARINDEX(',',@CustomerNumber)
  8.  
  9. while @pos > 0 begin
  10.     set @customer = LEFT(@customernumber,@pos-1)
  11.     set @customer = RTRIM(ltrim(@customer))
  12.     insert into @customers(custnmbr) values (@customer)
  13.     set @customerNumber = SUBSTRING(@customerNumber,@pos + 1 , 100)
  14.     set @pos = CHARINDEX(',',@CustomerNumber)
  15. end
  16.  
  17. set @customer = RTRIM(ltrim(@customernumber))
  18.  
  19. insert into @customers(custnmbr) values (@customer)
  20. select custnmbr from @customers

Tags:
Categories:
Location: Blogs Parent Separator DEVSHED Blogs Child Separator SQL
As always, I welcome your comments!
  
 
 
Home | Products | Blogs | Contact Us | Links | God's Plan
Privacy Statement | Terms Of Use
 
Copyright 2011 by Devshed.us