Seed feature in ApexSQL Generate

Applies to:
ApexSQL Generate

Summary:
This article will provide answers to FAQs about Seed feature in ApexSQL Generate.

Description:

ApexSQL Generate is a tool that is used to generate great number of test data to populate a database. To ensure randomization of the data generated, and allow for repeatability, the Seed feature can be used. The following question and their answers will provide better insight into the Seed value.

FAQs about Seed value

Q: What does the Seed feature do?

A: The Seed value acts as a key to unique set of data, and for each specific Seed value there is only a single set of random generated data created, by using the provided generator settings. This is used twofold, in one way the Seed value ensures that the random data generated is unique for each of Seed values, and the other way is to use the Seed value to recall the same random generated data that is connected to that exact Seed value.

Q: How does it work exactly?

A: The Seed value provides foundation for selection of random values from provided range of values. This is shown in the following example:

If the Seed value is set to 26, as a random choice from the available number of seeds, and the regular expression [0-9][0-9][a-d] is used in the Regular expression generator, the following set of data will be generated:

41b
48c
92a
32a
27a
36d

When the Seed value is changed to 7816, again randomly chosen from the available number of seeds, while using the same regular expression as in the example above, the following set of data will be generated:

27d
54c
73d
64c
65c
28b

Reverting back to the Seed value of 26, exactly the same set of the randomly generated data, shown in the first example, will be generated, thus enabling to repeat the generation of the required set of random generated data.

More information on the use of Regular expressions in ApexSQL Generate can be found in the article Using regular expressions (RegEx) in SQL server to generate randomized test data.

Q: Does a unique seed value generate the exact same sequence of numbers including order, values, and the same count?

A: Each Seed value is connected to exclusively one set of data which includes values randomly generated from a given range, their order, but not their count. The count is set manually. It is important to note that the generated set of data is affected by Seed, but also by a range of available values of the data. This dependency can be shown in the following example:

If the range in the Random generator is set from 0, as the minimum value, to 10, as the maximum value, and the Seed value is set to 39, as a random choice from the available number of seeds, the following set of data will be generated:

1
2
0
9
8
7

If the minimum value of the range is kept at 0 and the maximum value is changed to 15, while keeping the Seed value at 39 the following set of data will be generated:

1
4
0
14
13
10

Q: Why would someone need it, use it?

A: The Seed value can be used for testing in Business Intelligence (BI) planning. For the example if there is a HQ sales production server that needs to be tested against dozen of store databases that have large number of exactly the same inventory but various quantities of the items in that inventory, this is where the Seed value is used best.

The exact same Seed value will be used in generating the random inventory items for each of the test store databases, in order to simulate the exact same inventory in those databases. Also, to simulate different quantities of items in the inventory, for each of the test store databases a specific Seed value will be set to ensure that no single database will have the same random data generated that represent quantities.

Other example of the Seed value use in generating random data, would be in the multi-server environment where the generation of exactly the same random data across the server databases is used for performance testing. Using the same Seed value for generating the data for each database helps with better performance testing with providing exactly the same data for each database.

Q: What are the range of seed values that could be used?

A: Each set of generated data is represented by a number that is declaring the Seed value and that number can be in the range from 0 to 2,147,483,647.

Q: What does a 0 seed value do?

A: The number 0 as the Seed value still represents a specific set of randomized data. It doesn’t have any special value at all, it behaves exactly the same as any other Seed value.

Q: Can the seed value be empty, null? What happens in this case?

A: The Seed value cannot be empty or null because it is essential for the random data generation. If the value from this field is deleted it will be automatically set to 0 before any data is generated.

Q: What is the default value of the Seed?

A: Upon connecting to a database each column will have a unique, randomly defined, Seed value which ensures that no data generated will be exactly the same in any given column.

Q: What scope is seed used for? Project, database, table, and/or column?

A: The Seed is implemented at the column level, but there are options in ApexSQL Generate that enable to set the same seed for each column in a table, and for each table in a database.