ORDER BY giving wrong order
- by Cody Dull
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.