Query for log shrink

Oh men
I forgot the query for shrink the log in database SQL server
Please you guys help me out!
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mark WillsTopic AdvisorCommented:
Easiest is to use SSMS
Right click on DBname, => tasks => Shrink => Files
Choose transaction log (filename drop down)
Then shrink option should be REORG before releasing unused space.

DBCC SHRINKFILE(<TransactionLogName>, 1)
DBCC SHRINKFILE(<TransactionLogName>, 1)

Open in new window

And to find the log name to use
 SELECT name FROM sys.master_files WHERE type_desc = 'LOG'

Open in new window

BUT Please read : https://www.experts-exchange.com/articles/657/Managing-the-Transaction-Log-for-the-Accidental-DBA.html before you begin.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ErnestoAuthor Commented:
Oh men,
i run this
USE [1010];  
DBCC SHRINKFILE ([1011_log], 1);  

Open in new window

But the Log do not reduced
Please Help!
Mark WillsTopic AdvisorCommented:
what is your recovery model for that DB ?

When was the last LOG backup ?

You should do a full backup and a log backup. the log backup is an important step.....

The T-SQL I posted above has 3 steps, not 1.

Or, try the SSMS approach. If possible give a a screenshot of the shrink files screen
Vitor MontalvãoMSSQL Senior EngineerCommented:
Ernesto, the transaction log won't be truncated if there are active transactions. You should also perform a transactional backup before running the shrink command.
If you know that you won't need the actual transaction logs for a future Restore operation, then you can simply change the Database Recovery Model to Simple, shrink the log file and change again the Database Recovery Model to Full. Do not forget to perform a Full Backup after, to start a new backup chain or the scheduled transactional log backups will fail.
Vitor MontalvãoMSSQL Senior EngineerCommented:
Ernesto, is this issue solved?
A feedback will be appreciated.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.