Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Nicer way of doing this
Message
De
01/01/2015 13:45:52
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Versions des environnements
SQL Server:
SQL Server 2014
Application:
Desktop
Divers
Thread ID:
01612941
Message ID:
01612946
Vues:
54
>I think this solution is as pretty as it gets and you don't find anything better.
>

Whether PIVOT or CASE is prettier/cleaner - that's subjective and everyone can decide for themselves. (Some lengthy debates on the MSDN forums for years and I know you were part of the discussions)

My personal opinion is that I'd rather read a PIVOT statement than a CASE statement, especially for a long query. The long case statements can get a bit cluttered, but I realize many experienced SQL people don't like PIVOT. Just my 2 cents.

It would be nice if there was a more elegant solution but I doubt you'll ever see that covered in an ANSI SQL standard. (Yes, someone could use dynamic SQL for a long list like this one).

But on the "better" - while SQL will usually generate identical execution plans, I would argue that the PIVOT is, more often, a bit more efficient on the total elapsed time from IO statistics (certainly not by a significant amount)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform