Hi,
i have a requirement like if any record of ABC is in the given roll_no then all other records of ABC in the same table also should be moved to same roll_no (with extra two conditions), so i created a self join like the one in below and its working fine, but my reviewer says self join will be slower instead of this - first load all the condition matching records in a temporary table and then based on the temporary table modify the original table.
so i am looking for any link or online material where it is mentioned like this temporary table approach will be faster than self join, please help me understand it better. many Thanks.
[code]
DECLARE @ROLL_NO INT
SET @ROLL_NO = (select ROLL_NO from tb_RollNumbers where S_NAME='ANAME')
UPDATE I1
SET I1.A_NO=I2.A_NO,
I1.A_ID=I2.A_ID,
I1.A=I2.A,
I1.D_DATE=I2.D_DATE
From TB_TABLE I2,TB_TABLE I1
Where I1.M_NO=I2.M_NO
AND I2.A_NO=@ROLL_NO
AND I1.A_NO<>@ROLL_NO
AND I1.S_ID='ABC'
AND I2.S_ID='ABC'
AND I1.TOT=10
AND I2.TOT=10
[/code]