srionline2k6
asked on
Copy three months records of about 20 million of data from 200 million of records using the date range and some where condition
Hi I have a query where I have to copy the ~ 2 millions of records to another dummy table from 200 millions of records with some condition with ID as Clustered Primary key
These are Based on two conditions:
1. Recent 3 months of data needs to be copied based on the date range... datatype is datetime which is in the form of following: '2010-02-11 01:25:00.670'
2. There is Description column which says 'Unknown Code 0'. Copy other than those records.
. How can I define the range of date by not hard coding the values I just want to pass the range of date by passing into variables using @min and @max
Is it easy to acheive using temp table or CTE's or is there any easy method that can copy huge data.
Thanks,
These are Based on two conditions:
1. Recent 3 months of data needs to be copied based on the date range... datatype is datetime which is in the form of following: '2010-02-11 01:25:00.670'
2. There is Description column which says 'Unknown Code 0'. Copy other than those records.
. How can I define the range of date by not hard coding the values I just want to pass the range of date by passing into variables using @min and @max
Is it easy to acheive using temp table or CTE's or is there any easy method that can copy huge data.
Thanks,
Can't you have non-clustered index on your date column? Also if you can add description in include list of that non-clustered index. If so then u could use between construct in ur where clause to filter records for 3 months as per @min and @max along with description. You could temporarily hold these selected records in temp table that is again cluster indexed on ur Id. From there use them the way you desire.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER