help with multi-valued integer paramater using a stored procedure

Posted on 2011-05-05
Last Modified: 2012-05-11
I cannot get this to work. I am using ssrs 2008.   I am using the udf list_to_tbl ValentinoV created in is blog and my stored proc is the following.  I created the dataset in ssrs and I can get it to retrive on value (225), but not mulitple values (225,226,229).  My values are like this 225,226,229.

ALTER procedure [dbo].[stp_load_test](@fin_nbr int)

declare @local_fin_nbr int
set @local_fin_nbr = @fin_nbr

select distinct customer_nbr_txt, Financial_Company_Nbr from DimCustomer
where Financial_Company_Nbr IN(select * from list_to_tbl(@local_fin_nbr))


ALTER FUNCTION [dbo].[list_to_tbl] (@list nvarchar(MAX))
   RETURNS @tbl TABLE (number int NOT NULL) AS
   DECLARE @pos        int,
           @nextpos    int,
           @valuelen   int

   SELECT @pos = 0, @nextpos = 1

   WHILE @nextpos > 0
      SELECT @nextpos = charindex(',', @list, @pos + 1)
      SELECT @valuelen = CASE WHEN @nextpos > 0
                              THEN @nextpos
                              ELSE len(@list) + 1
                         END - @pos - 1
      INSERT @tbl (number)
         VALUES (convert(int, substring(@list, @pos + 1, @valuelen)))
      SELECT @pos = @nextpos
Question by:elucero
    1 Comment
    LVL 22

    Accepted Solution

    @fin_nbr and @local_fin_nbr as both declared as int. So these can never hold more than one number. Try to declare them as nvarchar(MAX) also and see if that helps.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Suggested Solutions

    How to use Variables  and Custom code in SSRS report and Assembly reference to use compile shared code in SSRS. Its big question for all who are working with SSRS. It is easy to create assembly and refer in SSRS report, still there are some steps…
    It is helpful to note: This is a cosmetic update and is not required, but should help your reports look better for your boss.  This issue has manifested itself in SSRS version 3.0 is where I have seen this behavior in.  And this behavior is only see…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now