In this walkthrough I will show you how to use Red Gate SQL Data Generator to generate test data for a database. While writing software which interacts with a database developers often write scripts to insert some data. Usually this data is not big enough to find performance bottlenecks and/or issues with presenting data on UI. An application may work well under the load of dev data and possibly test data but becomes a different beast when run against proper production data. So the question is how do you get some real looking data. There are two options; one you can ask your friendly DBA to give it to you, second you can generate your own data which mimics production data at-least in size. In this post I will deal with the second. I will show you how easy it is to generate good quality test data.

As a disclaimer I’d like to say that Red Gate did not pay for this post in any form. I installed a 14 day trial of Red Gate SQL Data Generator and I liked the tool.

 

Creating SQL Data Generator Project

SQL Data Generator works with projects which are .sqlgen files. The project file stores settings such as database you are generating data for and few other settings such as should Insert Triggers be fired. A project can be created by clicking on the New Project  button on the toolbar which brings this dialog

image

You can specify the database server and the database name  here. For this walkthrough I will generate data for Northwind database. After supplying database values click OK and it will import schema information from database.

The main windows displays the tables for which data will be generated. You can exclude tables by clicking on the checkbox.

image

On the right side of the window you can set the number of rows to be generated, what should be done when data is invalid and you can choose if existing data should be deleted.

image

For this example let’s set number of rows to be 100,000 for customer table and do the same for few other tables. I think that is a good number to do some testing.

Clicking Generate Data button on the toolbar presents this dialog which presents a summary of actions which will be taken.

image

Once the data is generated successfully a report is presented which shows the number of rows inserted for tables.

image

A quick query on Northwind database in SSMS shows a sample of newly inserted data.

image

And that’s how easy it is to generate data which can be used for load testing, and finding performance bottlenecks while developing an application.

Tagged with:
 

One Response to Walkthrough – Generate Test Data With Red Gate SQL Data Generator

  1. Ranjeet says:

    HI
    Is there any means by which we can control the distribution of generated test data.

    i.e I have a ‘VISIT’ table with a column name ‘VISIT TYPE’ [with any one of three types of input data 'Inpatient','Outpatient' or 'Emergency'], so i would like to generate the data in such a manner that 60% of the generated data should be ‘Inpatient’, 20% should be ‘Outpatient’ and 20% should be ‘Emergency’.[If we are generating 100 rows for visit table then 'VisitType' column should contain 60-Inpatient , 20-Outpatient,20-Emergency data rows]

    Regards,
    Ranjeet

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>