Running SQL Server commands in Windows requires the use of SQLCMD commands, which are installed when you install SQL Server.
Use SQLCMD to enter interactive mode:
The previously used commands are:
DatabaseName With no_log databasename with no_log --Truncate transaction log DBCC SHRINKDATABASE (databasename) -- Shrinking a Database
These commands need to be executed sequentially and are often much faster than using the "shrink" command directly in the right-click menu.
However, this command does not work under the 2008 version and is limited to sql2005~
SQL2008 is optimized for file and log management by using the following command: Clear the log in simple mode, and then revert back to full mode when the purge action is complete
DatabaseName DatabaseName SET RECOVERY Simple databasename godbcc shrinkfile (N 'databasename_log ', one, truncateonly) GO
Revert to Full mode
DatabaseName DatabaseName SET RECOVERY Full--revert to complete mode go
SQL Server 2008 Purge logs