Avatar of ibgadmin
ibgadmin
Flag for United States of America asked on

Cannot shrink log file because of min log space.

I had this question after viewing Cannon shrink log file because of minimum log space required..

I found the above answered question.  I have a similar issue but someone initially told us to use sp_replflush.  We did that but still receive can't shrink because of min log space required.  What do we need to do so we can shrink the log file.  The database is a test db that was restored from a production db that had replication on it but don't need on the test db.  I guess we need all the steps involved when we copy a production db with replication to a test environment without it having any log transactions to fill from replication.
Microsoft SQL Server

Avatar of undefined
Last Comment
Vitor Montalvão

8/22/2022 - Mon
ibgadmin

ASKER
BTW - we are running SQL Server 2012 Standard
Vitor Montalvão

The database is a test db that was restored from a production db that had replication on it but don't need on the test db
I think that's your main problem. You created the database from a restore so it will keep the Production configuration. In SQL Server, you can't shrink a file to a size lower that when it was created.
My suggestion to solve this issue is to perform a transaction log backup followed by a shrink log file on the Production database, back it up immediately and restore it in your test machine so it will restore with a smaller transaction log file.
Qlemo

No clue if that works, but how about adding a log file, migrate transactions to it, and then remove​ the old one?
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
ASKER CERTIFIED SOLUTION
ibgadmin

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Vitor Montalvão

ibgadmin, if your issue is solved, please close this question.
ibgadmin

ASKER
Issue resolved - I was able to resolve this by running a log backup TWICE on the test db.  I read that somewhere in a thread about issues with shrinklog about running twice.  Thanks for your help.
Vitor Montalvão

As per author's comment
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.