How to repeat key values [population Method] when we use SQL statement generator

We get population method with 3 different options when we select manual foreign key generator. But for most of the time I'm using SQL statement which doesn't have population method. Please help in repeating key values when SQL statement is selected to generate values
Tagged:

Answers

  • Alex BAlex B Posts: 1,131 Diamond 4
    Hi @yateesh_kumargd,

    I'm not sure if I quite understand your question, but for what I believe you mean - you should be able to use this option to repeat the values until the required number of rows is met:


    If I have misunderstood can you please elaborate on what you are trying to achieve and include a screenshot if possible!

    Kind regards,
    Alex
    Product Support Engineer | Redgate Software

    Have you visited our Help Center?
  • Hi Alex,

    I was looking for highlighted option for SQL Statement generator ..
    Right now SQL statement has only 'Loop until...' option, but I want to repeat key values even I use SQL statements.   
    Ex: Consider I want to generate 9000 rows for a table. For one of the column I will make use SQL statement generator that result set is 300 keys. I want to repeat the keys 30 times [ that is row 1- 30 will have the same key value in a column, next 30 rows will have same value and so on .] so that 300 keys will be distributed among 9000 rows .

    Right now this can be done only when I use foreign key(manual) generator. But if I use SQL statement which might have where clause to get specific value there is no option to repeat the key values


  • Alex BAlex B Posts: 1,131 Diamond 4
    Hi @yateesh_kumargd,

    Perhaps I'm not understanding, but the same values result in either case:

    If you use the SQL Statement generator to provide 300 values and you say "loop until required number of rows is reached" with the number of rows being 9000, you will end up with 30 rows for each of the 300 values... I'm not sure how the order of the information in the table matters, since you can sort by that column to have all the values next to each other if you query it.

    For example, if I query as FK generator and it produces e.g. 1,1,2,2,3,3,4,4,5,5 (for 10 rows) that is essentially the same as writing a SQL Statement that returns the values 1-5 and me saying loop until all rows are full for 10 rows (which would insert as 1,2,3,4,5,1,2,3,4,5, but if I were to then query that table in either case and ORDER BY myFkCol DESC they would both show up as 1,1,2,2,3,3,4,4,5,5 so the same data is in there.

    Kind regards,
    Alex
    Product Support Engineer | Redgate Software

    Have you visited our Help Center?
  • How can I do this with python script ?
Sign In or Register to comment.