Link to home
Start Free TrialLog in
Avatar of brokeMyLegBiking
brokeMyLegBiking

asked on

best way to shrink database file sizes

What is the best and safest way to shrink the mdf and ldf files of my databse? I use the following command:

DBCC SHRINKFILE(sfs_dat, truncateonly)
DBCC SHRINKFILE(sfs_log, truncateonly)

I have also used this command, but I think truncateonly is healthier. Is that correct?

DBCC SHRINKFILE(sfs_dat, 1)
DBCC SHRINKFILE(sfs_log, 1)

I see some people recommend this command. Why the backup log command does that force sqlserver to do some cleanup internally or something?

DBCC SHRINKFILE(<TransactionLogName>, 1)
BACKUP LOG <DatabaseName> WITH TRUNCATE_ONLY
DBCC SHRINKFILE(<TransactionLogName>, 1)

and final question: Is the only difference between DBCC SHRINKFILE and DBCC SHRINKDATABSE, that DBCC SHRINKDATABASE does all files?
ASKER CERTIFIED SOLUTION
Avatar of Aneesh
Aneesh
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of brokeMyLegBiking
brokeMyLegBiking

ASKER

ok, thx