Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
A very unique situation
Message
De
04/02/2014 14:07:44
 
 
À
04/02/2014 00:09:58
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Versions des environnements
SQL Server:
SQL Server 2008
Application:
Web
Divers
Thread ID:
01593091
Message ID:
01593190
Vues:
25
The following will avoid having to deal with a long WHERE IN clause as it will dump everything into #Temp and use it after to get the final SQL select command with all the fields that are needed.

This example includes a sample example of collecting 9 keys. But, in real life, this would be a bunch of conditions to determine which keys I need to collect.
SELECT Country.Numero INTO #Temp FROM Country WHERE Numero<10
SELECT Country.Title_E,Country.Title_F FROM Country WHERE Numero IN (SELECT * FROM #Temp)
The example shown above is just to demonstrate the approach. In real life, we have some very complicated SQL select commands but could use the same approach so to only collect the primary keys at first and then a simple select to get the rest of the fields.

Is this pretty much a considered optimized approach to handle that situation?
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform