Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
jruez
Starting Member
5 Posts |
Posted - 2008-03-20 : 17:34:27
|
I am creating a database for an application through script. After the tables, views, and sp's are created, the database is populated with data. After all of this (and before the application is even run), the log file is about 700MB. If I shrink the database, it takes the log down to 1MB. The mdf file is about 165 MB before and after it has been shrunk.I have two questions:1. Is there something I should look for in my database scripts or is there a setting that could prevent this from being created so large.2. Is there a script I can run in my sql code after the database has been created and populated to shrink it. Thank you for your help |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-03-20 : 21:59:39
|
1. Insert the data in smaller chunks and commit after each chunk.2. Check out DBCC SHRINKDB and DBCC SHRINKFILE in SQL Server Books Online.But I wouldn't bother with your script. Just run your script once, get the database exactly how you want it including the file sizes, then detach the database. Copy the MDF and LDF files to another location and then reattach. When you want to deploy your database elsewhere, just grab those MDF and LDF files and attach them to the new server.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
jruez
Starting Member
5 Posts |
Posted - 2008-03-21 : 00:28:05
|
Thanks Tara, I will take a look at those. I appreciate your help. |
 |
|
|
|
|