Solved

SQL Express - Define my database as MODEL and create new databases from it

Posted on 2009-05-13
6
480 Views
Last Modified: 2013-12-25
Hello everybody again,

We have a framwork from which we devise websites for customers and the framework runs on top of a SQL Server Express database.

I'd like to know what would be the quickest way to define my database as a Model database and create duplicates of this database to deploy other websites.

As of now I run a .sql file which populates an empty db and inserts the needed data to it.
Recently we made some upgrades to our framework and the ammount of data to be inserted on the db grew quite a lot, thats why I think theres gotta be an easier and faster way of doing this, considering that I have administrator's access to the database server instance.

Thanks

Eder
0
Comment
Question by:Ederwainer
  • 4
  • 2
6 Comments
 
LVL 5

Accepted Solution

by:
Aanvik earned 500 total points
ID: 24378769
You can do backup/restore which could be really fast, only if you are not interested in running sql script.
0
 

Author Comment

by:Ederwainer
ID: 24379193
I was successful at creating a .bak file from our model database.
However, when I create a new database it asks me who is the owner, and for each database we create we also need to create a unique owner (user).

How do I create the user prior to creating the database, so I can point to him as the owner when I create the new database?

Thanks!

Eder
0
 
LVL 5

Expert Comment

by:Aanvik
ID: 24379224
Its simple. Create a user with a SQL statement in the Target database and while restore you should be able to use that user.
You should be able to restore with SQL statement as well... as long as .bak file is in predefined location.
0
Give your grad a cloud of their own!

With up to 8TB of storage, give your favorite graduate their own personal cloud to centralize all their photos, videos and music in one safe place. They can save, sync and share all their stuff, and automatic photo backup helps free up space on their smartphone and tablet.

 

Author Comment

by:Ederwainer
ID: 24379270
Ok,

I found where I can create a new user. Ill go trhough the process and see how it goes.

Thank you so far!

Eder
0
 

Author Comment

by:Ederwainer
ID: 24385867
Im having some trouble with it and I could use some further guidance.

I made a .bak file from our oficial database and stored it on the server.
Then I create a new user, create a new database  and go to Tasks -> Restore, choose device as the source and point to the .bak file I created.

Then I come across an error that implies that the .bak file can be restored only the the database from which it was originated. Is that so?

If that is so, this might not be the best method, as what I need to do is to created databases that are duplicate of our official database, however with difeerent names, to be owned by different logins and be used in different websites.

Thanks

Eder
0
 

Author Comment

by:Ederwainer
ID: 24391525
I got over the problem described above. However I came across a new difficulty,

When I generate the .bak file, the default schema is exported along with it. However for security purpose I dont want to use the same schema for all databases and I can accomplish that by populating the db from a .sql query, as it will apply the schema based on the name of the user that owns the newly created database.

How can I have a unique schema for each database if when I restore from .bak it will apply the existing schema instead of using the schema of the database being restored to?

Thanks again.

Eder Wainer
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

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

Suggested Solutions

Data center, now-a-days, is referred as the home of all the advanced technologies. In-fact, most of the businesses are now establishing their entire organizational structure around the IT capabilities.
If you're not part of the solution, you're part of the problem.   Tips on how to secure IoT devices, even the dumbest ones, so they can't be used as part of a DDoS botnet.  Use PRTG Network Monitor as one of the building blocks, to detect unusual…
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

895 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now