Today one of my friend ask me, can we use Order by clause dynamically ? I said yes, but there are few limitations while using case in order by clause see the below example. This script will return Error: DECLARE @TOP INT = 10, @FLD VARCHAR(20)='AGENT_ID' SELECT TOP(@TOP) * FROM ( SELECT 1 AS...