Reaching other table data.
shnek
Posts: 4
Is reaching data from other table possible?
I need for example to set expiration date in table X that is less by the date in table Y by random number of days.
I have one more question. When in table X i have a column with integer number: 1, 2 or 3; so how can I generate in table Y the exact same number of rows that are the known number from table X, of course the table Y is connected with table X.
I need for example to set expiration date in table X that is less by the date in table Y by random number of days.
I have one more question. When in table X i have a column with integer number: 1, 2 or 3; so how can I generate in table Y the exact same number of rows that are the known number from table X, of course the table Y is connected with table X.
Comments
Yes it is possible to get data from another table - there is the Generic > SQL Statement generator that will allow you to get data from a column in another table. In your example you would choose the SQL Statement generator, set up the connection and then use the following SQL Statement to get a random number of days (between 1 and 10) subtracted from it using the DATEADD functionality:
SELECT DATEADD(dd, -(Abs(Checksum(NewId())) % 10), date1)
FROM table1
Where date1 is a datetime column in table1 (your Y) and the generator is set on a datetime column in table2 (your Y).
More information on how the random number is generated:
http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/sql-server-set-based-random-numbers/
For your second question you can use an existing datasource, where it will insert the data provided in the existing column/table, as detailed here:
http://documentation.red-gate.com/display/SDG3/Mapping+SQL+tables+or+views
Have you visited our Help Center?