Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Select and Update from CTE
Message
 
 
À
30/06/2015 15:11:33
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2012
Application:
Web
Divers
Thread ID:
01621599
Message ID:
01621622
Vues:
39
>>So, for that parent, which child row (AddDate) do you want to grab?
>
>That would be the same we are deleting. So, the goal is to update the parent from Invoice.AddDate value, but just before we remove the child record. So, basically, we are trying to simulate in time the parent value as if the unnecessary child record would not have been created.
>
>As per verification, in the second line, it was supposed to be 1.
>
>
>SELECT InvoiceTemp.NoClient,InvoiceTemp.AddDate FROM InvoiceTemp
> WHERE InvoiceTemp.RowNumber=1 AND InvoiceTemp.NoStatus=7 AND
>  EXISTS (SELECT InvoiceTemp.Numero FROM InvoiceTemp AS InvoiceTemp2
>   WHERE InvoiceTemp2.RowNumber=2 AND InvoiceTemp2.NoStatus=7 AND InvoiceTemp.NoClient=InvoiceTemp2.NoClient)
>
>
>With that, it works.

If you want to delete multiple child rows per parent, which child's row would you like to use to update parent?
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