Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Enhancement actual select to update all rows
Message
 
 
À
03/01/2013 14:57:00
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2008
Application:
Web
Divers
Thread ID:
01561223
Message ID:
01561332
Vues:
30
>>I know it will not change the output, but UNION without ALL does distinct select and in your case you don't want a distinct. In other words, you don't want extra work which is done with DISTINCT.
>>
>>Merge syntax is documented well in BOL, for your case it will be
>>
>>MERGE myTable as target
>>USING (query with UNION ALL) as source
>>ON target.ID = source.ID
>>WHEN MATCHED 
>>   THEN UPDATE
>>    SET Totals = Source.Totals
>>
>
>Actually yes, I need the records from the first union including as well as the records of the second union. As, the way it is, the second union cannot return a record which has been returned in the first union. So, the sum of all will do.

Are you saying that your query will always return just one row per each Numero? BTW, did you have a chance to run your query as a MERGE command? I am thinking it may return an error in your case that UPDATE FROM will not return (see Erland's blog). So, I am curious in the outcome.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform