One more doubt, does the query really needs EXCEPT clause?
The below query alone would give the desired results, am I right?
SELECT [TableName] ,[ColumnName],[RecordId],[ReasonDesc]
FROM [GlobalIndex].[dbadmin].[DataValidation]
where CreateDate >= '28-Jun-2013'
and CreateDate < '29-Jun-2013'
Then the query will have only one scan on the table.Thanks
Sarat
Please use Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful.
Building on the answers given here, there are a number of problems with your query.
1. As mentioned, no indexes. I would agree that a clustered index on your unique identifier would improve performance.
2. Your query is not sargeable, Sarat's answer above is a sargeable query, although it doesn't exclude the required date ranges you require.
3. You're storing your dates as strings. This is probably the underlying problem in your query as a whole. If these were stored in the datetime date format, you could exclude the dateranges with a simple query like this:
SELECT [TableName]
,[ColumnName]
,[RecordId]
,[ReasonDesc]
FROM [GlobalIndex].[dbadmin].[DataValidation]
where CreateDate BETWEEN '2013-06-28 00:00:00.000' AND '2013-06-29 00:00:00.000'
Thanks.
No comments:
Post a Comment