Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ORDER BY CASE
Message
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Miscellaneous
Thread ID:
01436398
Message ID:
01436414
Views:
39
>>I'm not sure what you're telling us here? Do you mean to use this technique then the Order By field is passed as a parameter?
>>
>>If yes, then
>>
>>case @OrderBy when 'DateField' then DateField when 'SomeOtherField' then SomeOtherField end
>>
>>Also, what about DESC / ASC ?
>
>Yes, that's the syntax. just add the asc/desc after the END

I know - the question is how to control it dynamically.

In other words, if you pass

@OrderBy varchar(50)
@SortOrder int (1 -- ASC, 2-- DESC)
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform