>>This is weird UPDATE statement. I suggest to start from the SELECT with JOIN into a temp table and see how long that SELECT will work.
>>
>>If the select finishes in reasonable time, then still keep the temp table approach and just do UPDATE after the select based on PK.
>
>What would be the difference with this:
>
>
>UPDATE Client
> SET MyDate=
> (SELECT COALESCE((SELECT TOP 1 Invoice.AddDate FROM Invoice
> WHERE Invoice.NoClient=Client.Numero
> ORDER BY Invoice.Numero DESC),'1899-12-30 00:00:00'))
>
>
>In that one, I also do a massive update where the inner select includes the relational of each update to be done (Client.Numero).
>
>This one works ok.
This is one to one relationship and in the other case it's not 1 to 1. But I would not write this UPDATE that same way also. I'd rather use CTE and ROW_NUMBER approach.
It's a bad idea to write UPDATE that way. Check out this blog post
Dear FROM clause...This is one of my many favorites of his blogs.
If it's not broken, fix it until it is.
My Blog