Solved

SQL Transaction logs

Posted on 2016-11-29
8
43 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
  • 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
Backup Solution for AWS

Read about how CloudBerry Backup fully integrates your backups with Amazon S3 and Amazon Glacier to provide military-grade encryption and dramatically cut storage costs on any platform.

 
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

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

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

Suggested Solutions

Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

730 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