Dump Tran for all DBs

  • Hello,

    How can I dump tran for all DBs, I have the following but it gives me error:

    exec sp_msforeachdb ' use[?];

    dump tran db_name() with truncate_only'

    Thanks.

  • I found the solution:

    exec sp_msforeachdb ' use[?];

    DECLARE @DBName VarChar(150);

    SET @DBNAME = db_name();

    DUMP TRAN @DBNAME WITH TRUNCATE_ONLY'

  • Why are you truncating the transaction logs? Do you know what that's going to do to your log chain and your ability to restore to point-in-time?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • The logs are getting full every so often and we do not know why. One of the reasons could be that we are running profiler from time to time.

    Thanks.

  • Profiler won't cause a transaction log to grow.

    You need to investigate the matter, not just throw away the ability to recover your database. Start by querying sys.databases and looking at the log_reuse_wait_desc for the database. If it's log backup then check that your log backups are running correctly.

    If you don't need the ability to restore to a point in time, if restoring to the last full backup and losing all data since then is acceptable in the case of a disaster, switch the database to simple recovery model.

    Please read through this: http://www.sqlservercentral.com/articles/64582/

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Thanks Gail. That was really helpful.

  • note that DUMP is an old keyword and likely to be removed at some point. BACKUP TRANSACTION is preferred

    http://msdn.microsoft.com/en-us/library/ms186865%28v=SQL.100%29.aspx

  • Thanks.

Viewing 8 posts - 1 through 7 (of 7 total)

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