• Sapen (10/11/2011)


    Hi,

    I see that my errorlog has grown up top 35gb. Is there a way i can shrink it...coz c:\drive is 180mb free space now..this is very urgent.

    Thanks

    You need to be careful truncating the log file for the database. The log is what allows you to restore your database if there is a failure.

    The way you truncate a log file depends on what version of sql server you are running. If you are going to truncate the log file I would suggest that right after you truncate it you create a backup of your database so you are covered.

    You should regularly backup your database and at that time you could truncate the log file.

    All of that being said, to truncate a log file in sql server 2008 you can switch between recovery modes:

    declare @dbname varchar(100)

    exec('alter database '+@DBNAME+' Set Recovery Simple')

    exec('alter database '+@dbname+' Set Recovery Full ')

    Your database name would have to be in the @dbname variable.