November 18, 2008 at 10:57 am
John
I reckon this...
[font="Courier New"] UPDATE [A] SET
[LAST_PAYMENT_DATE] = [P].[LAST_PAYMENT_DATE]
,[NEXT_PAYMENT_DATE] = .[NEXT_PAYMENT_DATE]
,[CUR_PAYMENT] = [P].[CUR_PAYMENT]
,[PMT_FREQ] = .[AVG_PMT_FREQ]
FROM [dbo].[Amortization] [A]
INNER JOIN [##PS] [P]
ON [A].[ID_NUMBER] = [P].[ID_NUMBER]
INNER JOIN [##PS]
ON [A].[ID_NUMBER] = .[ID_NUMBER]
WHERE [A].[TBL_SOURCEID] <> '1'
AND [P].[RECCNT] = 1
AND .[RECCNT] = 2
[/font]
...is functionally equivalent. The derived table doesn't seem to be required, nor the index hints.
The UPDATE [A rather than UPDATE TableName can under some circumstances make a dramatic improvement.
If you wish to use this, the you should check your SELECT and mine and ensure that the results are identical before running the UPDATE.
Cheers
ChrisM
Is it just me or are the edit windows getting wider and wider today?
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
November 18, 2008 at 11:51 am
Chris Morris (11/18/2008)
Is it just me or are the edit windows getting wider and wider today?
Heh, yeah, John is a bit tab happy. I usually use the prettifier to remove all the extra extra tabs so that I can read it :hehe:.
November 18, 2008 at 11:53 am
I ran both mine and your updated statement...
How do interpret the Execution plan??? or should I post this as new question?
mine a
mine b
urs a
urs b
November 19, 2008 at 2:14 am
Hi John
Compare the SELECT component of each statement.
Row count
Values if you feel it is necessary
Time.
This is what I mean by the SELECT component:
[font="Courier New"]SELECT [P].[LAST_PAYMENT_DATE]
,.[NEXT_PAYMENT_DATE]
,[P].[CUR_PAYMENT]
,.[AVG_PMT_FREQ]
FROM [dbo].[Amortization] [A]
INNER JOIN [##PS] [P]
ON [A].[ID_NUMBER] = [P].[ID_NUMBER]
INNER JOIN [##PS]
ON [A].[ID_NUMBER] = .[ID_NUMBER]
WHERE [A].[TBL_SOURCEID] <> '1'
AND [P].[RECCNT] = 1
AND .[RECCNT] = 2
[/font]
Cheers
ChrisM
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
November 19, 2008 at 4:19 am
Opps - already answered
November 19, 2008 at 4:20 am
Already answer - something wrong with my connection today.
Viewing 6 posts - 16 through 20 (of 20 total)
You must be logged in to reply to this topic. Login to reply