I have two tables
- Location Master (
[LocatioNo],[LocationName],[Description]) - Location Data (
[LocationNo],[LocationCode],[DDate],[BillNo],[Model],[Quantity],[SNo])
and a view involving the 2 tables which was created in SQL Server 2000
CREATE VIEW [dbo].[QueryLocation]
AS
SELECT TOP (100) PERCENT
dbo.LocationData.LocationNo, dbo.LocationData.LocationCode,
dbo.LocationData.DDate, dbo.LocationData.BillNo,
dbo.LocationData.Model,
SUM(dbo.LocationData.Quantity) AS Quantity,
dbo.LocationMaster.LocationName
FROM
dbo.LocationData
INNER JOIN
dbo.LocationMaster ON dbo.LocationData.LocationNo = dbo.LocationMaster.LocatioNo
GROUP BY
dbo.LocationMaster.LocationName, dbo.LocationData.LocationNo,
dbo.LocationData.LocationCode, dbo.LocationData.DDate, dbo.LocationData.BillNo,
dbo.LocationData.Model ORDER BY dbo.LocationData.BillNo
When the following query is execute in SQL Server 2000 the result in the grid was sorted on billno column.
SELECT * FROM QueryLocation
After upgrade to SQL Server 2008 the same query when executed is not sorted on bill no field
Advice why this is not sorted on the group by column
Thanks in advance


ORDER BY- therefore, SQL Server does not guarantee any order! If you need a specific sorting, then you need to specify that with anORDER BY. If SQL Server 2000 did this - it was a coincidence which you should not rely on ... – marc_s Feb 25 '12 at 17:02