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...

6 Steps 1 min read Medium

Step-by-Step Guide

  1. 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.
  2. 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.
  3. Step 3: Create a New Query in MS SQL 2008 and copy the linked code into it.

  4. Step 4: Press F5 to execute the linked code.

  5. 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.

  6. 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

C

Christina Jones

Enthusiastic about teaching hobbies techniques through clear, step-by-step guides.

83 articles
View all articles

Rate This Guide

--
Loading...
5
0
4
0
3
0
2
0
1
0

How helpful was this guide? Click to rate: