sql server - T-SQL IF statements in ORDER BY clauses -
is there way can like @sorttype select * table order -- if sorttype == id table.id -- else if sorttype == date table.date how syntax look? thanks. there's gotcha here... can't mix data types in case statement, need create different groups of case statements different data types. select * table order case when @sorttype = id table.id end asc, case when @sorttype != id table.date end asc related blog post: http://dirk.net/2006/11/14/dynamic-order-by-with-case-statement-in-sql-server-data-type-issues/