Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
A little SQL quiz
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2005
Application:
Web
Divers
Thread ID:
01602842
Message ID:
01602848
Vues:
64
>
>SELECT SalesManID, xmonth, V
>  FROM dbo.SalesTemp  AA
>   UNPIVOT (V FOR XMONTH IN (Jan, Feb, Mar)
>           ) XDATA
>
Exactly, thanks very much.

The UNPIVOT (as well as the CROSS APPLY) will usually generate execution plans that are much better than the "older" approach

I inherited some code last year with a table that had several million rows and about 50 columns, and it initially used the "older" approach. It took minutes to run. Changed it to use UNPIVOT and it ran in seconds.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform