Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All

I am facing a problem related to database backup and restore. I have single database and having different companies. I store all the companies data in single database using company id. Now my problem is i want to take individual company backup (.bak) using backup query. Is it possible to take back up of individual company? If we succeeded to take individual company backup then how can we restore it again?
Posted
Comments
Rockstar_ 29-May-13 0:24am    
you can write query for getting data based on companyID, then insert all those records to a new table then take backup. Do this for all CompanyId's.

1 solution

Sooooo, you mixed all different company information into the same database? Well, backups work only on databases or filesets, not on the data in the tables in them.

I think you seriously screwed up your database design if you backing up and restoring individual companies was a requirement. You should have made databases for each and every company seperately. Now, you have a nasty little security problem. What if the companies queries get messed with?? One company can now look at the data for another!
 
Share this answer
 
Comments
Amol Salunkhe 29-May-13 0:41am    
Thanks Dave for reply

But actually fact is i am online registering company name and generating its id, so that's why i mixed all different company information into same database. Now i want to give individual back up to all companies.
thatraja 17-Oct-13 7:34am    
5!
Dave Kreskowiak 29-May-13 7:57am    
OK, so then the only way to extract individual companies is to run SELECT queries to pull the data for each company into temporary tables, backup those temp tables.

Your BIG problem is being able to restore that information. It's not easily done and could corrupt your primary keys. I'm not going to say anything about how to do that because I'm not going to be responsible for destorying your database because we don't know enough about your database structure.

Get a real live DBA in there to consult on your situation.
Amol Salunkhe 29-May-13 13:37pm    
Thanks Dave for your valuable suggestion

This is already happened, Now i can not make any changes in database....

Can you give me any suggestion if same case will happened in future i.e. How can I manage different database backup for different companies or any other things
Dave Kreskowiak 29-May-13 14:26pm    
Consult with a DBA before you going off writing the most important piece of your code.

I'm not saying anything further on this subject because You don't know anything about the requirements of an app that doesn't exist yet. I don't want to tell you because suddenly it becomes the hammer you use for every problem like this. It may or may not be appropriate as a solution for your next app.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900