Solved

SQL Transaction logs

Posted on 2016-11-29
8
51 Views
Last Modified: 2016-11-29
Have 2008 R2 SQL server.  Had an issue over the weekend that caused the transaction log of one of the DB to fill up (DB is 6gb, Transaction log was 911gb!)  I configured maintenance plan thinking after the full backup, those logs would be shrunk but they haven't, my recovery mode is set to full,   I was thinking of setting to simple, shrink DB, and set back to full if that would clear the logs out.  But shouldn't maint. plan be doing that?
0
Comment
Question by:leadtheway
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 25

Expert Comment

by:Lee Savidge
ID: 41905715
Is the maintenance plan backing the logs up as well? In full recovery you HAVE to back up the logs as well as the database.
0
 
LVL 25

Expert Comment

by:Lee Savidge
ID: 41905717
Oh, and don't shrink the database. Back the logs up and shrink the logs
0
 
LVL 1

Author Comment

by:leadtheway
ID: 41905835
yes theres a separate job for backing up the logs, but its not cleaning them,  how would I shrink the transaction log DB, ?
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 25

Accepted Solution

by:
Lee Savidge earned 500 total points
ID: 41905862
Something like this:

BACKUP LOG MyDB TO DISK = N'X:\Backup\MyDB_log.bak'
GO
DBCC SHRINKFILE('MyDB_Log', 1)
GO

Open in new window

0
 
LVL 1

Author Comment

by:leadtheway
ID: 41905893
ok when i look at the datapath for the DB in question i see 2 files

DBName= primary datafile
DBName_1=Transaction Log file, so in your scenario by doing below


BACKUP LOG DBNAME TO DISK = N'X:\Backup\DBName_log.bak'
GO
DBCC SHRINKFILE('DBName_Log', 1)
GO


That would just backup the transaction log file and then shrink it right, i don't have to specify the DBNAME_1 listed above?
0
 
LVL 25

Expert Comment

by:Lee Savidge
ID: 41905900
My code example is telling SQL to back up the log for the database named MyDB so you give it the name of the database. SQL will get the log file name from the database properties. No you don't specify the name of the log file until you tell ShrinkFile which file you want shrinking.
0
 
LVL 1

Author Comment

by:leadtheway
ID: 41905908
so in this case for the dbcc Shrinkfile i would specify the name of the log file in the datapath (dbname_1)
0
 
LVL 1

Author Comment

by:leadtheway
ID: 41906279
i ended up doing a combination of putting in simple recovery mode and then doing shrinkfile, cleared the neccessary space
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There have been several questions about Large Transaction Log Files in SQL Server 2008, and how to get rid of them when disk space has become critical. This article will explain how to disable full recovery and implement simple recovery that carries…
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question