Click here to Skip to main content
15,890,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i can reduce .ldf file size with help of given query but i can't reduce size in .mdf file

ALTER DATABASE [testdb] SET RECOVERY SIMPLE WITH NO_WAIT
DBCC SHRINKFILE(testdb_log, 100)
ALTER DATABASE [testdb] SET RECOVERY FULL WITH NO_WAIT
GO

What I have tried:

i just truncate some unwanted tables
Posted
Updated 17-Aug-16 3:16am

First of all - do NOT shrink a database (or its files) without good reason...SQL will perform better if you let it allocate the files in the way finds it best...
If despite this you have to shrink, than do not shrink a database in use. Shrink is a very IO expensive operation and doing it while other users are logged in will disturb their work.
SQL
DBCC SHRINKDATABASE (db_name-to-shrink)
 
Share this answer
 
You could try DBCC SHRINKDATABASE[^] but it won't stay shrunk for long once updates start happening...if you get any significant size reduction at all. Remember that the MDF file stores your data - and if there is a lot of data, you can't free up much space.
 
Share this answer
 

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