John said:
Hi
I need to copy records from table A to a new table B (overwrite if exists)
based on a flag field not set in table A
First, I'd use this
http://www.knowdotnet.com/articles/datasetmerge.html to
copy the data from the first table to the second. If you are sure you want
Table A's data in B, I'd go ahead and do a Truncate Table (if you are in SQL
Server) or Delete * from Table B before INserting. This will give you all
of the records in A's query in Table B.
Now, you can just do one more commmand
Update TableA Set FlagField = FlagSet where SomeKeyValue in (SELECT KeyValue
from TableB)
Or, you could just use the same where clause in the Select statement you
used to fill the dataset with and use that where clause in your update
statement instead of the subquery. If you have values in B already and you
use the subquery, you'll set evreything in A that matches B to Flagged,
whereas if you use the same where clause then you'll only update the records
that you moved via the select statement.
Let me know if you have any questions.
Bill
.. I then need to set flag for all
records in table A that are also in table B. How can I do this in ado.net
using vb.net?
Thanks
Regards
--
W.G. Ryan, eMVP
http://forums.devbuzz.com/
http://www.knowdotnet.com/williamryan.html
http://www.msmvps.com/WilliamRyan/