title: How to pass multiple values to single parameter in stored procedure
body: <p>I'm using SSRS for reporting and executing a stored procedure to generate the data for my reports</p>
  
  <pre><code>DECLARE @return_value int
  
  EXEC    @return_value = [dbo].[MYREPORT]
          @ComparePeriod = 'Daily',
          @OverrideCompareDate = NULL,
          @PortfolioId = '5,6',
          @OverrideStartDate = NULL,
          @NewPositionsOnly = NULL,
          @SourceID = 13
  
  SELECT  'Return Value' = @return_value
  
  GO
  </code></pre>
  
  <p>In the above when I passed <code>@PortfolioId = '5,6'</code> it is giving me wrong inputs </p>
  
  <p>I need all records for <code>portfolio id 5 and 6 also</code> is this correct way to send the multiple values ?</p>
  
  <p>When I execute my reports only giving <code>@PortfolioId = '5'</code> it is giving me 120 records
  and when I execute it by giving <code>@PortfolioId = '6'</code> it is giving me 70 records</p>
  
  <p>So when I will give <code>@PortfolioId = '5,6'</code> it should have to give me only 190 records altogether, but it is giving me more no of records I don't understand where I exactly go wrong .</p>
  
  <p>Could anyone help me?
  thanks</p>
  
  <p><img src="https://i.stack.imgur.com/PkPLv.png" alt="enter image description here"></p>
  
  <p>all code is too huge to paste , i'm pasting relevant code please suggest clue.</p>
  
  <pre><code>CREATE PROCEDURE [dbo].[GENERATE_REPORT]
  (
      @ComparePeriod VARCHAR(10),
      @OverrideCompareDate DATETIME,
      @PortfolioId VARCHAR(50) = '2',   --this must be multiple 
      @OverrideStartDate DATETIME = NULL,
      @NewPositionsOnly BIT = 0,
      @SourceID INT = NULL
  
  )  AS
  BEGIN   
  SELECT  
              Position.Date,
              Position.SecurityId,
              Position.Level1Industry,
              Position.MoodyFacilityRating, 
              Position.SPFacilityRating, 
              Position.CompositeFacilityRating, 
              Position.SecurityType,
              Position.FacilityType,
              Position.Position
  
          FROM
              Fireball_Reporting.dbo.Reporting_DailyNAV_Pricing POSITION WITH (NOLOCK, READUNCOMMITTED)
           LEFT JOIN Fireball.dbo.AdditionalSecurityPrice ClosingPrice WITH (NOLOCK, READUNCOMMITTED) ON
                      ClosingPrice.SecurityID = Position.PricingSecurityID AND
                      ClosingPrice.Date = Position.Date AND
                      ClosingPrice.SecurityPriceSourceID = @SourceID AND
                      ClosingPrice.PortfolioID IN (
                  SELECT
                  PARAM
                  FROM
                  Fireball_Reporting.dbo.ParseMultiValuedParameter(@PortfolioId, ',')                                             )
  </code></pre>