title: SSRS Not sorting correctly
body: <p>I'm tapping into a SQL Server 2014 database using SSRS 2014. I've used SSRS from its initial release but have never experienced this problem so I don't know if its a bug in SSRS 2014. I have a stored procedure that returns some data, something as simple as this:</p>
  
  <pre><code>CREATE PROCEDURE [dbo].[GetNewsletterStories] 
      @NewsletterID int,
      @IsMainStory int=2 --2 is both, 1 is true, 0 is false
  AS
  BEGIN
      SET NOCOUNT ON;
  
      SELECT
          ns.SortOrder as SortOrder,
          ns.Title,
          ns.Description,
          ns.LinkText,
          ns.LinkURL,
          ns.PictureName,
          ns.IsMainStory
      FROM
          NewsletterStory ns
      INNER JOIN
          Newsletter n
      ON
          n.NewsletterID = ns.NewsletterID
      WHERE
          n.Deleted=0
          AND ns.Deleted=0
          AND n.NewsletterID = @NewsletterID
          --do they want non main story or main story or both
          AND ((ns.IsMainStory = 0 AND @IsMainStory=0) OR (ns.IsMainStory = 1 AND @IsMainStory=1) OR (@IsMainStory=2))
      ORDER BY 
          ns.SortOrder
  END
  </code></pre>
  
  <p>If I run the stored procedure from within Management Studio like so:</p>
  
  <pre><code>USE [MyDB]
  GO
  
  DECLARE @return_value int
  
  EXEC    @return_value = [dbo].[GetNewsletterStories]
          @NewsletterID = 1,
          @IsMainStory = 1
  
  SELECT  'Return Value' = @return_value
  
  GO
  </code></pre>
  
  <p>I get exactly what I need in the correct order:</p>
  
  <p><img src="https://i.stack.imgur.com/49QFK.png" alt="enter image description here"></p>
  
  <p>Then I'm in SSRS and I create my dataset and can go to the query designer and run it:</p>
  
  <p><img src="https://i.stack.imgur.com/7UsUf.png" alt="enter image description here"></p>
  
  <p>Here is where it prompts me for my parameters:</p>
  
  <p><img src="https://i.stack.imgur.com/m6BJR.png" alt="enter image description here"></p>
  
  <p>I get exactly what I needed:</p>
  
  <p><img src="https://i.stack.imgur.com/QO1f9.png" alt="enter image description here"></p>
  
  <p>So far so good, I added my tablix and set its dataset name I created and even went as far as setting the sorting section to <code>[SortOrder]</code> based on the column in my dataset:</p>
  
  <p><img src="https://i.stack.imgur.com/r6OdN.png" alt="enter image description here"></p>
  
  <p>Every time I run my report I get the wrong sort order:</p>
  
  <p><img src="https://i.stack.imgur.com/KT1WS.png" alt="enter image description here"></p>
  
  <p>Simple I thought, it must be caching some old version, so I made sure to delete my reports <code>MyReport.rdl.data</code> file so that I get a fresh report. Nope that too still shows "Concerto Integration" first and then "RIMS Newsletter"...but my dataset and my stored procedure is returning the right order "RIMS Newsletter" and "Concerto Integration". I've tried everything but it always seems to be sorting by the primary key of the table (when the article was created, as I created the Concerto Integration article before the RIMS Newsletter article).</p>
  
  <p>I don't know where else to look, I even inspected the resultant XML (view code feature) and the <code>SortOrder</code> is in the dataset. Even if I remove that <code>SortOrder</code> it should work because the stored procedure is already sorting by it as you see in the code.</p>
  
  <p>What gives?</p>