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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Reduce DB size by truncating / droping tables?

Author  Topic 

zeeshan13
Constraint Violating Yak Guru

347 Posts

Posted - 2010-08-26 : 15:01:14
Hi All,

I have a Database. I notice that it has some large size physical tables which I can remove without causing any issues to increase disk space on the drive. I am either truncating those tables or droping them. Either way the database size remain same although available free space size start increasing. How can I reduce the size of the database as soon as I truncate or drop a large table in the database? Please suggest.

Thanks,

Zee

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-08-26 : 15:04:48
If you want to reduce the file size of the data file, then you will need to run DBCC SHRINKFILE on it. Do this only if you need the space though and only if you now you don't need the space in the next 6 months or so. Shrinking the file causes performance issues, so be very careful with this.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

zeeshan13
Constraint Violating Yak Guru

347 Posts

Posted - 2010-08-26 : 15:10:21
Thanks tkizer.

Can you please get me the vode for DBCC SHRINKFILE? And which file I be shrinking?

Thanks again.

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-08-26 : 15:13:45
Here's an example:

DBCC SHRINKFILE ('LogicalFileNameGoesHere', SizeInMegaBytesGoesHere)

See Books Online for details.

You can also use the GUI for this. Right click on database, tasks, shrink, files...

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -