Competition: What’s your favorite Redgate tool? Enter now.

Regarding SQL STATEMENT generator

Hi ,

I have tables like:

1. Rep(RepID, rep_name,Active) -> has id= 1 to 100 records
2. Role(RoleID, RoleCode, Active) -> has id = 1 to 30 records
3. RepRole(ID, RepID, RoleID)

and I need to populate the below table:

Table_1(id,name, created_repID,Created_RoleID).

So i am generating the data for created_repID randomly between 1 to 100. And I need to populate the Tables_1.Created_roleID from the REPROLE table for that respective Created_repID. How can I do this in RedGate generator tool?

Here i tried to write a query:
how to complete the below query. I need to pass the table_1.Created_repID as the parameter to the below query.
"Select RoleID from RepRole where repid =" + ?;

please give me a suggestion.

Comments

  • Brian DonahueBrian Donahue Posts: 6,590 New member
    Hi,

    It's not documented but I have been told that Data Generator cannot use newly-generated values to populate another column, so it wouldn't be possible to access data that has not yet been inserted into the database.

    You could use a foreign key generator or foreign key (manual) generator to populate values from one column into another column.
Sign In or Register to comment.