Click here to Skip to main content
15,889,281 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I need an expert advise on SQL Server DBs. What is better option for distributing the DBs. Actual DBs that could be attached to Server Instance through my code or .BAK files that could be restored?

Thanks
Posted
Updated 14-Mar-12 5:05am
v2

1 solution

Depends on the amount of data. If you are distributing a pretty-much-blank DB, I would distribute it via CREATE scripts as these compress very well. Since most DB files are allocated in multiple of megabytes there tends to be a lot of unused space in most.
If you have significant amounts of data, I would distribute the DB itself rather than a BAK file, purely because it should be faster to install at the other end.
 
Share this answer
 
Comments
Furqan Sehgal 14-Mar-12 11:09am    
So there is no drawback of distributing DBs instead of .Bak?
OriginalGriff 14-Mar-12 11:31am    
There are always advantages and disadvantages. :laugh: If you are distributing the DB itself, then you need the LDF file as well as the MDF, and you need the DB offline when you make the file copy. So, if you are always going to distribute the current status of the DB, then BAK files are a little less hassle. But against that there is the configuration headache of monitoring and recording who got what and when, so if there is a problem you can tell what they have. If you are doing a one-off copy into a distribution package then I would still try to go with scripts if I could.

Thinking aboput it, you may need NDF files as well for a DB install, so maybe BAK is better.

I would be tempted to go with a script distribute, with an online bulk update to the latest data!
Dave Kreskowiak 14-Mar-12 11:31am    
Depending on the version of the database you create the backup on and the version your installing on, you may not have the option of restoring it.

For an installation, I'd depend on a CREATE operation far more than I would a database restore.
OriginalGriff 14-Mar-12 11:39am    
Very good point! I hadn't thought of that...
Pity you can't 5 a comment. I'll save it for the next time I see one of yours I can.
Dave Kreskowiak 14-Mar-12 12:22pm    
I watched as someone tried to restore a database backed up on SQL Server 2008 and tried to restore it on a SQL Server 2000 box. They just couldn't understand why it wouldn't work! I kept my mouth shut to prolong and enjoy the festivities.

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