I am executing below query
declare @date datetime
set @date='28-Jun-2013'
SELECT [TableName] ,[ColumnName],[RecordId],[ReasonDesc]
FROM [DataValidation]
where CreateDate >= @date
and CreateDate < (@date+1)
Except
SELECT [TableName] ,[ColumnName],[RecordId],[ReasonDesc]
FROM [DataValidation]
where CreateDate between '20-Jun-2013' and @date
order by 4
It is taking more than 5 min but if I remove "Order by" clause then it took only one second. Below is execution plan without order by clause -
Why this is happening? how should I get rid of this?
Thanks in advance
No comments:
Post a Comment