Please help. Redgate data generator. How to use column of another table in python script?
Yay
Posts: 1 New member
I want to calculate difference between two numerical values that are in another table but have to input in this table along with text. Eg. Sentenced to 2 years. Now i want to calculate the value '2' and add text "sentenced to". How do i do that. Please help.
Tagged:
Answers
Hi @Yay
Thanks for reaching out on the Redgate forums regarding your SQL Data Generator question.
The Python scripting is good for referencing columns in the same table your script resides but fails to pick up values in other tables.
The SQL Statement generator would possibly be better used for your cross-table data referencing.
Example - a source & target table, in my source I am generating a numeric value between 1-5
In my target table; I have a SQL Statement generator that is concatenating text & the lookup value from the other table based on a key value pair.
Would this process be suitable for your requirements?
If you are using the value as part of a more complex Python script it may be necessary to first create another column in your target table and then using a SQL Statement generator to populate the data, and then reference that newly created column within your Python script