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
Solved

shrink log files to a database in sql server 2008 r2 configured mirror mode

Posted on 2014-03-20
2
922 Views
Last Modified: 2014-03-31
Hello,
I would need to know which is the correct way to do the shrink log files to a database in sql server 2008 r2 configured mirror mode.
thanks
0
Comment
Question by:pozlu0
2 Comments
 
LVL 39

Accepted Solution

by:
lcohan earned 500 total points
ID: 39943052
From http://technet.microsoft.com/en-us/library/ms191235(v=sql.105).aspx
a "Backup of the principal database is allowed, but BACKUP LOG WITH NORECOVERY is not allowed" you can shrink the file after a regular T-log backup or issue a explicit CHECKPOINT against that database then use the SSMS UI to "Shrink Files" and select the Log file of the DB you want to shrink.

or by T-SQL:


Simple recovery model
USE dbname
CHECKPOINT -- commit all uncommitted transactions
--First param below is fileno for log file, often 2. Check with sys.database_files
--Second is desired size, in MB.
DBCC SHRINKFILE(2, 500)
DBCC SQLPERF(LOGSPACE) --Optional
DBCC LOGINFO --Optional
Now repeate above commands as many times as needed!


Full or bulk_logged recovery model
USE dbname
BACKUP LOG dbname TO DISK = 'C:\x\dbname.trn'
--First param below is fileno for log file, often 2. Check with sys.database_files
--Second is desired size, in MB.
DBCC SHRINKFILE(2, 500)
DBCC SQLPERF(LOGSPACE) --Optional
DBCC LOGINFO --Optional
Now repeate above commands as many times as needed!
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

791 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