Buzz Burhans wrote:
Is there any way to use Stata's -odbc- command to append to or replace an MS
Access table if the appended or replacement data has either new or different
variable names than those that already exist in the Access table?
Alternatively, is there a way to automate the deletion of an Access table
(but not the Access database) from within Stata?
Using -odbc insert,...insert- or -odbc insert,...overwrite- fails if the
table variable names are not the same in the existing table and either the
appending (insert) or the replacement (overwrite).
--------------------------------------------------------------------------------
You can associate the Stata variables names back to the Access database
table's names on-the-fly during the append or overwrite operation using
the -odbc insert . . ., as()- option. Try something like:
odbc insert primary_key newvariable1 newvariable2, ///
table(. . .) dsn(. . .) insert ///
as(primary_key oldcolumn1 oldcolumn2)
There is also a SQL statement that you can execute via -odbc exec()- that
will DROP TABLE. And you might even be able to work something out with
ALTER TABLE, but it would probably be convoluted. (Check the Microsoft
Access Help under "Microsoft Jet SQL Reference" tab and open the "Data
Definition Language" to find how the statements work.) But it sure sounds
as if it would be far safer and easier to go the -odbc insert . . ., as()-
route.
Joseph Coveney
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/