how to clear the sql transaction log?

  • my .ldf file has grown over 2 GB and i need to shrink it or clear it. or even delete completely.

    is it possible?

    thank you.

    edit: i'm a developer using SQL express so the log is useless to me.

  • vadimt (11/14/2007)


    my .ldf file has grown over 2 GB and i need to shrink it or clear it. or even delete completely.

    is it possible?

    thank you.

    edit: i'm a developer using SQL express so the log is useless to me.

    Well, it is possibly useful :), but that is another story. If it is not useful for you, then switch to simple recovery.

    What recovery mode are you running this database in? (you can get this information from the master.sys.databases view)

    If you are in full, then change to simple recovery model.

    alter database mydb set recovery simple

    You can also then truncate the log:

    DBCC SHRINKFILE ('mydb_log',1)

    GO

    Regards,

    Andras


    Andras Belokosztolszki, MCPD, PhD
    GoldenGate Software

  • You ca also add: BACKUP LOG [Yourdatabase] WITH NO_LOG

    Finally, you have:

    BACKUP LOG [Yourdatabase] WITH NO_LOG

    ALTER DATABASE [Yourdatabase] SET RECOVERY SIMPLE

    DBCC SHRINKDATABASE ( [Yourdatabase], TRUNCATEONLY )

  • Thakns.

    helped a lot.

  • If you just want to shrink the log:

    select name from sysfiles (to get logfile name)

    dbcc shrinkfile(logfilename, SizeInMB)

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply