keeping the data structure of two tables in sync using SQL
Posted on 2003-12-05
I have two tables with similar data structures. One is the main table and the second is an audit table for the first which has all the same columns of the first plus two columns which keep track of who made a change and when. I'd like to write a SQL statement that helps me keep them in sync. The statement should:
1) Query the data structure of the first table.
2) Look for any changes to column names, new columns, deleted columns, or changed data types as compared to the second table.
3)change the structure of the second table to match the first, without affecting the first two columns of the second table.
first table columns:
second table columns:
The solution can be a SQL statement in a DTS package or stored procedure.
How is <i>that</i> for a challenging question?! Thanks a ton in advance.. if anyone can solve it!