SQL Data Generator - 1.2
Learning SQL Data Generator - 1.2
Setting up data generation
This topic provides an overview of how you set up SQL Data Generator to generate data.
You are recommended to back up the database that you are going to populate before you generate the data; you can then adjust the settings and repeat the data generation if you are not happy with the results.
To generate data, first create a project by selecting the SQL Server and database you want to populate. The project also defines some options for the data generation, and you can specify any number of SQL scripts that you want SQL Generator to run automatically before or after generating the data.
When you have created a project, the schema of the database you selected is listed in a tree view in the Tables to populate pane.

You specify the tables that you want to populate by selecting the Populate check box. By default, these are all selected, but you can change this option for both new projects and new tables in your application options (accessed from the Tools menu).
To see the creation SQL script for a table, right-click the table or column name in the tree view and click Show Schema Creation Script.
When you have selected the Populate check box for a table, you can define how you want the data to be generated: click the table name in the Tables to populate pane, and specify the details in the Table generation settings pane.

You can choose to:
- create data using generators
SQL Data Generator automatically assigns a generator to each column based on its table name, column name, data type, and length. If the column has constraints, SQL Data Generator uses these to set the generator parameters for the column; if the constraints cannot be complied with in this way, the RegexpGenerator is assigned instead and an appropriate regular expression is set up. You can change the generator used by a particular column later if required. For detailed information, see About generators.
- import data
You can import a table or view from an existing database, or an existing CSV file. SQL Data Generator maps the columns based on name and data type. If any columns cannot be mapped, SQL Data Generator assigns a generator. You can change the mappings later if required. For detailed information, see Mapping SQL tables or views and Mapping CSV files.
Note that:
- foreign keys are automatically assigned the Foreign Key generator; this cannot be changed to a different generator, but you can customize its settings
- columns for which data is auto-generated display Server Assigned in the Generator box; this cannot be changed
For example, identity columns and computed columns are server assigned.
In the table generation settings, you can also specify the number of rows that you want to be generated, and whether you want existing data to be deleted prior to populating the table.
You can preview the data that will be generated for each table in the Preview pane.

You may see the following icons when the values for a column cannot be previewed prior to generation:
|
server-assigned column |
|
foreign key column |
|
computed column or a manual foreign key column |
You may also see warnings or errors in the preview.
When you have set the table-level parameters, you can check the settings for each column in the table, and customize them if required. To select a column for customization, click the name of the column in the Tables to populate pane, or click the column in the Preview pane.
When you are happy with the settings for all the columns that you want to populate, click
Generate Data. An action plan provides a summary of the data generation for you to review before you generate.
Scripts
You can run SQL scripts before or after the data generation. For example, you could use scripts to add custom data to the database. SQL Data Generator can run these scripts automatically.
You set up the scripts you want to run in the Project Configuration dialog box (click
Edit Project and select the Scripts tab).

You can link to external script files, or you can embed scripts by typing in the Project Configuration dialog box, (or a combination of the two). Scripts are run in the order in which you list them in the project configuration.
If a script that is run before data generation fails, the generation process is stopped.
If a script that is run after data generation fails, the process continues with the next script.
Warnings and errors
When you are setting up the tables and columns that you want to populate, SQL Data Generator displays warning and error messages to inform you when there may be a problem with the data generation.
|
Errors prevent you from selecting |
|
Warnings inform you when a problem may arise during data generation. The problem does not prevent you from generating data, but it may stop the data generation for a particular table. For example, a warning is displayed if you have chosen to delete rows in a table, but another table references it. |
|
Information messages provide you with information about issues that you may want to rectify, but which will not prevent data generation. For example, you may see an information message if SQL Data Generator cannot create enough rows for the preview. |
To see the details of an error or warning, hover your mouse pointer over the icon to display a tooltip, or click the column name to see the details in the Column generation settings pane.
Refreshing the schema
When you open a project, if the database schema has changed since you created the project, the schema that has changed is flagged with
in the Tables to populate pane. For example, a changed column is indicated by
and a changed primary key column is indicated by
.
To clear the flags, click
Refresh Schema.
You can also click
Refresh Schema to see any changes that have been made to the schema since you opened it. Click
Refresh Schema again to clear the flags.
Command line
When you have set up a SQL Data Generator project, you can use the command line to run the project. For more information, see Using the command line interface.
See also |
Was this article helpful?
SQL Data Generator
- Creating random GUIDs in SQL Data Generator
- Conforming to unique constraints in SQL Data Generator
- Generating data in improperly-named column causes System.InvalidOperationException
- Self-referencing table constraints can cause generation to stop
- Logging and log files
all SQL products
- Compatibility of Red Gate tools in 64-bit environments
- Application has encountered an error and needs to close
- Error message after installing SQL Toolbelt - The description for Event ID ( 1 ) in Source ( nview_info ) cannot be found.
- Changing the temporary directory used by the installer
- Toolbelt Installer "hanging" while "scanning volumes"
- Login failing with "trusted SQL Server connection" error when using RunAs
all products
- Some Red Gate products identified as containing a trojan by Anti-Virus software
- Activation may fail with Unknown Error -1
- Product uses web help although a CHM file is available locally
- Argument exception resulting from missing environment variable
- Check for updates may fail when used through proxies
- 'Unidentified Publisher' error when repairing or uninstalling
- Licensing activates product as standard edition
- Moving Red Gate software products to another machine
- Red Gate tools log locations
- The application UI opening slowly when there is no internet access
SQL Data Generator
- Activating your products
- Activating your products
- Getting help offline
- Cleansing or removing sensitive data from an existing data source
- SQL Data Generator release notes - version 1.xx
- SQL Data Generator release notes - version 2.xx
all SQL products
all products
- Red Gate product acknowledgements
- Activating your products
- Activating your products
- Red Gate bundle history
- Check for updates
- Troubleshooting Check for Updates errors
- Current versions
- Deactivating your products
- Installing Red Gate products from the .msi file
- Requesting additional activations
- Serial numbers for bundles
- Reactivating using a different serial number
- Extending your trial
- Finding your serial numbers
- Moving a serial number from one computer to another
- No response received for manual activation
- Licensing and activation resources
- Licensing and activation resources
- Troubleshooting licensing and activation errors
- Licensing and activation FAQs
- Red Gate tools log file locations
- Download old versions of products
- Download product prerequisites & utilities
- Support & upgrades
- Upgrading your software
- Upgrading FAQs

Using SQL Data Generator