Shrink or truncate SQL Server log file
It happens that the SQL Server have a large log file, and you don't need it. Here is the ways to shrink the log file:
Method 1:
Import the data to the database ( highlight the database->Tasks->Import data ),
or Export the data from the database ( highlight the database->Tasks->Export data )
Method 2:
Shrink the log file to the desired size, for example, 1MB. That is, highlight the database->Tasks->Shrink->Files
set the file size, say, 1MB.
Method 3 ( Eliminate the log file completely):
In the SQL Server Management Studio,
- Highlight the database-> Tasks->Detach..-> Click OK
- Go to log file folder -> rename the testDev_log.ldf to be like testDev_log-aa.ldf,
- Highlight Databases->Attach-> Click Add -> add the database testDev, highlight the log file and click the Remove button. This means you only attach testDev.mdf
- After this is done, you can verify the contents of the attached database and then delete the log file.
Method 4
USE Site2
GO
DBCC SHRINKFILE('Site2_Log', 1)
BACKUP LOG Site2 WITH TRUNCATE_ONLY
DBCC SHRINKFILE('Site2_Log', 1)
GO