Just a day ago I have received following email from Siddhi and I found it interesting so I am sharing with all of you. The question was about shrinking NDF and MDF files and whether it loses data.
DBCC SHRINKDATABASE (dbName)DBCC SHRINKFILE (logicalLogFileName)USE dbName EXEC sp_helpfile
/* Shrink Whole AdventureWorks Database */ DBCC SHRINKDATABASE (AdventureWorks) GO /* Get the Logical File Name */ USE AdventureWorks EXEC sp_helpfile GO /* Shrink MDF File of AdventureWorks Database */ DBCC SHRINKFILE (AdventureWorks_Data) GO

Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.com.
Discover more from SQL Authority with Pinal Dave
Subscribe to get the latest posts sent to your email.





58 Comments. Leave new
Hi Pinal,
I was checking shrinking mdf file.
Found tons of article advising not to shrink.
As that will create problem with the indexes.
Can you please share some suggestions ?
Thanks!
how to purge data older than 24 months in sql server 2008 R2 database
Hello, and I hope you help me
I have .ndf file that this file is too large, 45GB. We have not many data in this database. I shrink db and ndf file, but the size does not change.