Hello,
I have 10 tables (T1Orj,T2Orj,…T10Orj) and I need to find modified rows from each table and insert them to T1Bak, T2Bak, …T10Bak. Although original and bak tables have the common fields , the original tables have more fields than bak tables, and T1Orj, T2Orj, … T10Orj tables have different table structures.
I can go head and write a insert into query for each table, I am just wondering Is there any way I can do this in a loop for all tables?
You can use a dataadapter to do this:DataSet ds =newDataSet();SqlDataAdapter adp =newSqlDataAdapter("select * from authors; select * from sales","server=srv;Integrated Security=true;database=pubs");
adp.Fill(ds);
In this case the dataset ends up with two tables,
one for authors and one for sales.
If you want you can then go and rename them, as they end up with names like "Table", "Table1", "Table2", etc.
but they come out in the order you put in ....
then you can do
No comments:
Post a Comment