|
AskSQLTeam
Ask SQLTeam Question
USA
0 Posts |
Posted - 02/12/2001 : 09:11:20
|
Elisabeth writes "I want to create a stored proc similar to the examples shown in your article 'dynamic ORDER BY'. But it's not possible to include a different sort order (ASC/DESC) in the ORDER BY case.
-- sample code--
CREATE PROCEDURE ps_Customers_SELECT_DynamicOrderBy @SortOrder tinyint = NULL AS SELECT CompanyName, ContactName, ContactTitle FROM Customers ORDER BY CASE WHEN @SortOrder = 1 THEN CompanyName ASC WHEN @SortOrder = 2 THEN CompanyName DESC ELSE ContactTitle END
Do you know have an idea how to solve this problem ?
Thank you" |
|