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:
00545618
Vues:
10
>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

Hi Mike,

I've tried several variations and I still can't get it working. I've also looked in my SQLServer books as well as BOL, but I can't figure this out. I'm sure its a stupid little goofy typo on my part, but would you mind sending me a "very simple" complete select statement using the case idea when you get a chance.

I can't wait to get this working...will save me gobs of time with future asp pages calling this stored proc.

I used to do quite a bit of VFP a couple of years ago, but my IS dept. (which includes 0 programmers) insists that all devp. must be with SQLServer, so here I go again, at the bottom of the learning curve :( , Oh well.

Thanks again for your time.

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

Click here to load this message in the networking platform