Dynamic result ordering in SQL
There are several methods to implement the dynamic ordering of result returned by SQL query. The examples of stored procedures below use the Microsoft's demo database AdventureWorks.
USE AdventureWorks
GO
Sequence of IF..ELSE
The sequence of IF..ELSE looks not so pretty but is efficient and rapid. When you …