Reputation: 321
I'm using Red Gate SQL Data Generator 3. What I'm wanting to do is to generate test data where there are related fields in each row. For example, I want to generate a row of data that looks like this:
Programatically, I'd want something like (pseudo-code):
Generate _lastname, _firstname
_username = first-letter of _firstname + _lastname
Fullname = _lastname + ", " + _firstname
Username = "CONTOSO\" + _username
Email = _username + "@contoso.com"
All the data generator samples I saw were for a single field, and didn't allow or consider needing to populate a row with related fields. I did not see a means of doing this within the product directly. Also, at the moment, the user forums at Red-Gate are down, so no help there.
Is this possible to do within the product? If so, could somebody post an example?
Upvotes: 0
Views: 376
Reputation: 136
As a proof of concept, I created a dummy table with a primary key and some fields - firstname, surname, username and email.
firstname was just set to the generic "First Name" generator, as the surname was set to the "Last Name" generator.
I then used the "Simple Expression" generator for the username and email fields. The expression for the username generator was 'CONTOSO\\'+firstname[:1]+surname
. For the email column, the expression I used was firstname[:1].lower()+surname.lower()+'@contoso.com'
This image shows the resulting data I managed to generate
I hope this helps.
Upvotes: 3