I'm working on converting some queries from Sybase to Microsoft SQL Server. One of the things I need to correct is the "group by" usage. Sybase allows you to put non-aggregate items in the select clause that don't appear in the group by clause. MSSQL requires every non-aggregate to appear in the group by clause.
I can just add every missing item from the select into the group by, but I'm concerned about the return order. Will the order that the matches are returned change if I add the additional group by items? There may be code that's depending on the results to be returned in a particular order (bad, I know, but I have no control over that). If adding new group by items will skew the order, is there a quick & easy way to do it right?
Since I'm looking for general information on how group by results are ordered in Sybase versus MSSQL, I haven't posted a specific query's code. I need enough general information to go on and convert all these queries myself.