Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hmm :confused: I thought I just posted this as a topic, but it's not here.

 

Is there a way (.net code or otherwise) to make a copy of a database and strip away it's data?

 

I could copy and paste the database and delete records, but I have the TableID's (primary key) set to Autonumber. The clints will need to interact with a few of these table ID's and don't want them in the 1000's.

 

In other words, I need the same structure, but a new database, and I have specific records that need to go into the first few TableID's for some tables.

 

Sure, I'm lazy. I could 'remake' the database again. But this would take some time (possibly introducing new errors into the application) and is feasable once, but I'd prefer an automated method for future uses.

Posted

what database?

 

Access? Making a copy, deleting the data, and then compacting is easy and will reset your auto numbers. . .

 

SQL? generate the SQL schema script and execute it inside a new database. is easy, too

Joe Mamma

Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized.

Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.

Posted
Access? Making a copy' date=' deleting the data, and then compacting is easy and will reset your auto numbers. . . [/quote']

 

Still annoying to do it by hand.

 

The main point of programming is to replace repeditive simple tasks.

 

But I did not know that once you deleted everything on a table and compacted/repaired it, the autonum would reset.

 

In fact I'm still not sure what exactly compacting/repairing a database does, other than making the database smaller. I do it about once a day before I compress my project to save my days work and knock off between 50k and 600k (off of a database that's normally 300k)

 

Thank you for that knowledge :)

  • *Experts*
Posted

Compacting reduces size because Access is using the one database file as a virtual file structure. As records are added and then deleted, their old space is retained in the Database. Updates, I believe, are generally inserts and deletes (how they're handled internally) and so they leave unused space in the file where the "old" records were. A compact looks for these areas and cleans them up. You can think of a "Compact" operation as the same thing as a disk defragmenter - it cleans up unused areas and moves data around so that the "unused" stuff is at the "end" of the file, then truncates it out. More or less :

 

The main point of programming is to replace repeditive simple tasks.

As you said, that's what Programming is - if Access doesn't currently have a "Copy Database minus the Data" function, then you may have spotted a useful programming oportunity :)

 

If you happen to have SQL Server then you can "automate" the copying of the structure by using DTS, which can copy between Access databases. An option of DTS is to only copy structures. If you have a developer license to MSDN then you can install SQL Server tools (Enterprise Manager) to do this for you. As long as you're not managing an Access database used by your company (or you), then you don't need to buy a license to SQL Server to use the tools.

 

-Nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted
Compacting reduces size because Access is using the one database file as a virtual file structure. As records are added and then deleted, their old space is retained in the Database. Updates, I believe, are generally inserts and deletes (how they're handled internally) and so they leave unused space in the file where the "old" records were. A compact looks for these areas and cleans them up. You can think of a "Compact" operation as the same thing as a disk defragmenter - it cleans up unused areas and moves data around so that the "unused" stuff is at the "end" of the file, then truncates it out. More or less :

 

 

As you said, that's what Programming is - if Access doesn't currently have a "Copy Database minus the Data" function, then you may have spotted a useful programming oportunity :)

 

If you happen to have SQL Server then you can "automate" the copying of the structure by using DTS, which can copy between Access databases. An option of DTS is to only copy structures. If you have a developer license to MSDN then you can install SQL Server tools (Enterprise Manager) to do this for you. As long as you're not managing an Access database used by your company (or you), then you don't need to buy a license to SQL Server to use the tools.

 

-Nerseus

look into the JRO library

Joe Mamma

Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized.

Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...