SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 dynamic ORDER BY combining different sort order
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

AskSQLTeam
Ask SQLTeam Question

USA
0 Posts

Posted - 02/12/2001 :  09:11:20  Show Profile  Visit AskSQLTeam's Homepage  Reply with Quote
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"

graz
Chief SQLTeam Crack Dealer

USA
4138 Posts

Posted - 02/12/2001 :  09:11:20  Show Profile  Visit graz's Homepage  Reply with Quote
Please read the FAQ (http://www.sqlteam.com/FAQ.asp). I think the third item will answer your question.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000