Ask SQLTeam Question
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
ORDER BY CASE WHEN @SortOrder = 1 THEN CompanyName ASC
WHEN @SortOrder = 2 THEN CompanyName DESC
Do you know have an idea how to solve this problem ?