Shrink transaction log file in Sql Server

Command are as follows:

For Sql Server 2005

BACKUP LOG 
[DBNAME] 
WITH TRUNCATE_ONLY
DBCC SHRINKFILE(
[DBNAME]
_log)


For Sql Server 2008



ALTER
DATABASE [DBName]
SET
RECOVERY SIMPLE;
GO

-- Shrink the truncated log file to 1 MB.

DBCC
SHRINKFILE (DBName_log, 1);
GO

-- Reset the database recovery model.

ALTER
DATABASE [DBName]
SET
RECOVERY FULL;