How to: Specify the Number of Rows to Generate

To generate data, you must create and run a data generation plan. The data generation plan contains the information about which tables you want to fill and how many rows of data that you want to generate. For more information, see Data Generation Plans.

You can specify the number of rows of data that you want to generate for each table. You can set the number of rows in the following ways:

  • Set the number of rows to generate as a hard-coded number.

  • Set the number of rows to generate as a ratio to the number of rows that are generated in another table. You can use this method on tables that have a foreign key that references another table. For example, you might want to generate 10 rows of customers in a Customer table. Then you can generate 5 orders for each customer in an Orders table. If a table has more than one foreign key, you can only specify only one of them to use for the ratio.

Before you can specify the number of rows that you want to generate, you must open or create a data generation plan. For more information, see How to: Create Data Generation Plans.

To specify the number of rows to generate

  1. Open or create a data generation plan.

    The data generation plan, the Data Generation Preview window, and the Column Details window all appear in the Visual Studio designer.

    Note

    If the Column Details and Data Generation Preview windows are not open, you can open them by opening the Data menu, pointing to Data Generation, and then clicking the window name. By default, the Data Generation Preview window and the Column Details window are docked and tabbed at the bottom of the data generation plan window. To expand your view, click in the window, open the Windows menu, and then click Tabbed Document. You can also right-click in the title bar and then click Tabbed Document.

  2. Click in the data generation plan window.

    The data generation plan lists all the tables in the schema. You can change which tables are included in the data generation plan by using the check boxes in the Table column. For more information, see How to: Specify Tables for Data Generation.

  3. Click the row of a table for which you want to specify the number of rows to generate.

  4. Do one of the following:

    1. Click the Rows to Insert column, and type the number of rows to generate.

      Note

      By default, 50 rows are generated for a table. You can change the default by using the Options dialog box. For more information, see Options (Database Tools/Data Generator/General).

    2. Click the Related Table column, click the down arrow, and then click the table to which you want to specify a ratio.

      You can click any table that this table references by a foreign key. If no foreign keys are defined on this table, the Related Table column is blank. After you click a related table, the Ratio to Related Table column is filled automatically with the current ratio between the tables. The current ratio is calculated by using the current values of the Rows to Insert column. You can change the ratio by clicking the Ratio to Related Table column. Specify a ratio in the format N:M, where N is the number of rows to insert in this table, and M is the number of rows to insert in the referenced table. When you change this value, the Rows to Insert column is updated to show the new number of rows.

  5. On the File menu, click Save.

    Now that you have specified how many rows you want to generate, you can specify what columns you want to include. For more information, see How to: Specify Columns for Data Generation.

See Also

Tasks

Walkthrough: Creating and Running a Data Generation Plan

Concepts

Overview of Generating Data

Other Resources

Data Generator Walkthroughs