Hi guys,
I am looking for a clean way to forward some demo data using a stored procedure. The data that I want to forward are date types. Due to the nature of my app, some of the data in my app will only appear when certain dates in the data are in the future. I hope this makes sense. : S
Since my database is ever expanding, I was thinking to write a stored procedure which essentially forwards all dates in all tables in my database that belongs to a demo user account. I will also keep track of the date the demo data was forwarded last. Obviously the stored proc will get run on login of a demo data, and when the difference between last date the demo data was forwarded and the current date has met a certain time difference (e.g. 30 days). This way I do not have to keep altering the script as much.
Now to the technical part:
I am using this to retrieve all the tables in the db:
Select
table_name
from
Information_Schema.Tables
Where
TABLE_TYPE like 'BASE TABLE'
and table_name not like 'Report_%'
and table_name not in ('Accounts', 'Manifest', 'System', 'Users')
What I need is a way to iterate through the table names, find the column names and column types. Then I wish to update all columns in each table that is of type datetime. I have read looping in SQL is not ideal, but I would like to minimise the number of database calls rather than putting this on the serverside code.
Am I going down the wrong path to solve this issue?
Thanks in advance.