Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ORDER BY CASE
Message
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Divers
Thread ID:
01436398
Message ID:
01436414
Vues:
43
>>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform