Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Ordering
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Titre:
Divers
Thread ID:
00544830
Message ID:
00544985
Vues:
15
>As you probably found out, SQL Server does not allow a parameterized ORDER BY clause. OTOH, you can use the CASE function within the ORDER BY:
>
>SELECT ...
>FROM thetable
>ORDER BY CASE @resort
> WHEN 'City' THEN citycolumn
> WHEN 'State' THEN statecolumn
> ...
> OTHERWISE somethinghereifyouwant
> END
>
>The only thing to consider is that SQL Server will consider the data type of the CASE function based on the last item in the list. Make sure that you convert everything to the same data type.
>
>-Mike

Thank you Michael, I will give that a try.


John.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform