Solved

cloning databases

Posted on 2007-12-06
6
153 Views
Last Modified: 2011-09-20
Has anyone ever wrote an app where they keep each company in a seperate database, and there is also a master database... and when you create a new company, it automatically clones a starter database and names it the name they wanted, etc...  

I've never did anything like this... I was hoping someone could tell me the best way to do it, and the best way to apply changes.   Like if you want to change one stored procedure, then change it for all the children at once.  

I have some ideas on how to do it, but they seem like a decent amount of work to me... Maybe someone else has it down pat already...

Any code is appreciated...
0
Comment
Question by:picsnet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 21

Expert Comment

by:surajguptha
ID: 20421331
we use it this way
I have a company table containing 1,2,3,4 companies
and each table in the database has a company_id column indicating which company the row is for....

This way there is no need to create new databases, rather you could just have the same table for multiple companies...
0
 
LVL 1

Author Comment

by:picsnet
ID: 20421417
i know how to do it that way, but for this app.... i want this kind of architecture...  
0
 
LVL 21

Accepted Solution

by:
surajguptha earned 500 total points
ID: 20421536
As far as i know.....
Clone Table/ Databases for a SQL Server seems to be a product. Like this one
http://www.ombelt.com/clone/mssql/index.html
If you can get your hands on the source code of such a product or use it as a command line utility you can achieve the same
0
Monthly Recap

May was a big month for new releases from Linux Academy! Take a look at what our team built recently in our blog. You can access the newest releases from our blog.

 
LVL 1

Author Comment

by:picsnet
ID: 20421631
it is actually very simple....  i was just googling it... you create what you want your database to look like in the model database, and then everytime you create a database, then it will have everything that model has...

now the only thing i have to do is find a simple way to loop through the databases to create a new stored procedure or alter another procedure........

0
 
LVL 1

Author Comment

by:picsnet
ID: 20421875
and here is the other answer... prefix your databases with something, and then search for the prefix...  the only thing that sucks is that if you make a change to a stored proc... you have to write the whole thing out in dynamic sql to do this method...

It'd be nice to be able to make a change to model and then have a loop that tells every other database to grab the change from model, but i don't know if this is possible
0
 
LVL 1

Author Comment

by:picsnet
ID: 20421879
forgot the code

EXEC sp_MSForEachDB
 
'USE ? Select Db_Name()
      If Db_Name() = ''BevolutionMaster''
            Begin
                  Select * From Company
            End'
0

Featured Post

Comparison of Amazon Drive, Google Drive, OneDrive

What is Best for Backup: Amazon Drive, Google Drive or MS OneDrive? In this free whitepaper we look at their performance, pricing, and platform availability to help you decide which cloud drive is right for your situation. Download and read the results of our testing for free!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question