Ken McNamee has been thinking outside the SQL box. I didn't realize that you can use a "case" statement in the "order by" clause:
DECLARE @orderBy varchar(50)SET @orderBy = 'LastName'SELECT *FROM EmployeesORDER BY CASE WHEN @orderBy = 'LastName' THEN LastName END, CASE WHEN @orderBy = 'HireDate' THEN HireDate END
For more on this, see his post: http://blogs.vertigosoftware.com/kenm/archive/2005/12/06/Dynamic_ORDER_BY_Clause.aspx
Remember Me
a@href@title, b, blockquote@cite, em, i, strike, strong, sub, super, u
Page rendered at Tuesday, January 06, 2009 10:02:18 AM (Central Standard Time, UTC-06:00)
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.