USE <databasename> DBCC SHRINKDATABASE (<databasename>, 0); GONOTE: <databasename> is the name of the database which you want to shrink. The second parameter in the SHRINKDATABASE command denotes the percentage of free space you want to keep in the database. If you put 0 (Zero) it means the database will be shrunk to the minimum possible size. Script to shrink the transaction log
USE <databasename> GO ALTER DATABASE <databasename> SET RECOVERY SIMPLE DBCC SHRINKFILE(2,0) ALTER DATABASE <databasename> SET RECOVERY FULL GONOTE: <databasename> is the name of the database for which you want to shrink the transaction log. Recovery mode of the database needs to be changed to simple to shrink the log file successfully which must be changed back to full. The first parameter in the DBCC SHRINKFILE command denotes the file which you want to shrink and the log file is defined by the numeric value 2. The second parameter is as same as the SHRINKDATABASE command where 0 (Zero) is shown to shrink the log file to its minimum size. The above commands can be run through the SQL Query Analyser by connecting to the remote DB from your end. Hopefully this will help you to manage database files to keep them in size.
Most popular searches: Technology, Website, AI
Your may interested in our latest blogs