Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2001-02-12 : 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" |
|
|
|
|