How to Batch Process Millions of Records on Microsoft Sql
Create an empty table to which you want to process large data., Create a cluster index on the primary key field on the source table if it does not exists. , Create a New Query in MS SQL 2008 and copy the linked code into it., Press F5 to execute the...
Step-by-Step Guide
-
Step 1: Create an empty table to which you want to process large data.
Make sure the empty table has all required fields for your data. -
Step 2: Create a cluster index on the primary key field on the source table if it does not exists.
, Get the code from here The linked code assumes that you have a database named:
Utilities and you may need to change the name in the below script or create the same database.
Search for this line: "In here you place your code to process your records" and place the actual code for your tables for the batch.
Search for this expression: "MIN(Users_PK)" and replace the fields with your source table and PK. , It depends on your server speed how quickly the above should finish. ,, You may run that code when ever you want to see the process of that script. -
Step 3: Create a New Query in MS SQL 2008 and copy the linked code into it.
-
Step 4: Press F5 to execute the linked code.
-
Step 5: Create a New Query and copy the following code: "SELECT * FROM Utilities.dbo.BatchProcess ORDER BY DateTimeEntered DESC" and press F5 to execute it.
-
Step 6: While you run the above code in Step 5 you should see data as appear in the image below.
Detailed Guide
Make sure the empty table has all required fields for your data.
, Get the code from here The linked code assumes that you have a database named:
Utilities and you may need to change the name in the below script or create the same database.
Search for this line: "In here you place your code to process your records" and place the actual code for your tables for the batch.
Search for this expression: "MIN(Users_PK)" and replace the fields with your source table and PK. , It depends on your server speed how quickly the above should finish. ,, You may run that code when ever you want to see the process of that script.
About the Author
Christina Jones
Enthusiastic about teaching hobbies techniques through clear, step-by-step guides.
Rate This Guide
How helpful was this guide? Click to rate: