I have the below update query, its taking around 3 minutes to execute, I have around 1.5 million records present in "Data" table and 100000 records present in "Report" table, can someone help me in optimizing similar kind of update queries.
Update [Data] set [Invoice Number]=S.[invoice No], [Invoice Date]=S.[Invoice date],[From]=S.[From], [To]=S.[To],[Code]=S.[code] from [Data] A inner join [Report] S on RTRIM(LTRIM(A.[Order ID]))=RTRIM(LTRIM(S.[Order ID])) and S.UniqueID=' ABC' where A.[Final Status]='Valid' and A.UniqueID='ABC'