Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Query Optimization - Problem

Author  Topic 

dks_cse
Starting Member

1 Post

Posted - 2008-01-30 : 12:45:24
This is my query which is taking too much time -

Please suggest any efficient way to improve eecution time
Many thanks in advance!!!!
-----------------------------------------
Select [Transaction].OrderID,isnull((select top 1 Old_Value from finlog where finlog.orderID = e_Order.OrderID and
finlog.LastModifiedDate > [Transaction].lastModifiedDate and finlog.Column_Name = 'OperatorID'
order by finlog.LastModifiedDate asc),(e_Order.OperatorID)) as NewOperatorID FROM e_Order join
( select distinct(transactionid),lastModifiedDate,OrderID,OperatorID from finlog
where transactionid like 'O%'
and TABLE_NAME = 'e_Order'
)[Transaction] on e_Order.OrderID = [Transaction].OrderID
left join syncfinlog on [Transaction].transactionid = syncfinlog.transactionid
---------------------------------

cat_jesus
Aged Yak Warrior

547 Posts

Posted - 2008-01-30 : 13:14:58
Try using Common table expressions rather than derived tables and subqueries.

Also format the code into something less disjointed and more readable.
Go to Top of Page
   

- Advertisement -