Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SQL Transaction logs

Posted on 2016-11-29
8
Medium Priority
?
64 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
Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

 
LVL 25

Accepted Solution

by:
Lee Savidge earned 2000 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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

610 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