Shrink Database Files
SQL Allow you to shrink data and log file. You can shrink a file to a size that is less than the size specified when it was created. This resets the minimum file size to the new value. We will discussed here some ways to shrink database files. Before we move to shrink file using queries, first we need to get names of files which are attached to the database. Below is the query which is used to retrieve logical name of mdf and ldf files. Get Name of mdf and lfd file Syntax: USE Database_Name GO EXEC sp_helpfile GO Shrink database file using queries By using this query you will be find name of files. No we will move to use this file name into the query to shrink those files. Syntax: Use Database_Name DBCC SHRINKFILE (FileNameToShrink' , 1) SHRINKFILE requires two parameter. First is the name of file to shrink and other is size for the file in megabytes, expressed as an integer. If not specified, DBCC SHRINKFILE reduces the size t...