On 2019-03-02 08:14, Charlie-gm wrote:
Ok, I haven't done this in a while, but I think I have done this a few ways.
First, by "metadata" of the database, I assume you mean stored procedures, maybe table triggers, database comment field?
I'll also assume you are trying to run from within an .exe (so commands like COPY PROCEDURES TO... and APPEND PROCEDURES FROM ... will not be available)
So...
- if you know the "data model" of the dbc, you can open it like a
table - then look for the metadata items you want (the stored procedure code, trigger code, etc). Do a SCATTER MEMO NAME ... Then open the other DBC as a table and do an APPEND FROM NAME ... After everything is copied that way I think you will want to do a PACK DATABASE or maybe VALIDATE DATABASE on the backup. I seem to recall doing that.
- after you've copied all the tables, copy the "database files" with
"COPY FILE <orig> TO <backup>" - copy the dbc, dct, and dcx this way. Again a PACK or VALIDATE database may be needed afterwards. And of course, be careful with this, test it out, etc. But I definitely used this approach before.
- if you are not worried about the tables being opened at the time of
doing the backup, you could just do the "COPY FILE <orig> TO <backup>"
- that command allows paths in the from/to. Also, I think it allows
wildcards, so you could do a complete copy in 1 command. Of course, the downside is the assumption of files being closed.
Hi Charlie,
I've got VFP available so COPY/APPEND PROCEDURES is available. So I wrote a quick PRG and got the stored procedures just fine with that...but the part that's missing now is the table-specific data like default values (important as some call the usual newid('table') function in the default PK field) and captions (not important).
--Mike