ORDER BY giving wrong order

Posted by Cody Dull on Stack Overflow See other posts from Stack Overflow or by Cody Dull
Published on 2012-04-12T17:11:27Z Indexed on 2012/04/12 17:29 UTC
Read the original article Hit count: 329

Filed under:
|
|

I have an SQL statement in my C# program that looks like:

SELECT * FROM XXX.dbo.XXX 
WHERE Source = 'OH'
  AND partnum = '1231202085' 
ORDER BY partnum, Packaging, Quantity

When running this query in SQL Server Management, the results are ordered as expected. My first 3 results have the same partnum and Packaging with Quantities of 32.0, 50.8, and 51.0.

However, when I run the query from my program, the result set with quantity 50.8 is the first to be returned. The datatype of Quantity is decimal(18,9). I've tried cast, it doesn't appear to be a datatype problem.

I cant figure out why its getting the middle quantity.

© Stack Overflow or respective owner

Related posts about c#

Related posts about sql-server