×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

SQL 2014 Truncate Log File

SQL 2014 Truncate Log File

SQL 2014 Truncate Log File

(OP)
I have reviewed many of the posts her on truncating the log file.
I would like to completely remove the present log file on a production DB.
I have tried backing up the log but it fails, the DB back ups OK.
A checkdb on the DB shows no errors.
I can access the DB at night when nobody is using it.
I have seen that detaching, renaming the log file, and attaching the Db will force a new log file, but I have also seen warnings against this.
What is the safest and best ways to do this?
Sorry, I know this has been discussed many times but I want to make sure I do it correctly.

Auguy
Sylvania/Toledo Ohio

RE: SQL 2014 Truncate Log File

(OP)
Thanks I will check it out.

I'm going with this example as a template.
It worked on my test DB after I made a change.
For anyone using this code the Shrinkfile didn't work and gave me an error
Check your logical file name for the log file, mine was different than the DB name.
Shrinkfile worked once the correct logical file name was used.

select * from sys.database_files to get the logical name.

USE AdventureWorks2012;
GO
-- Truncate the log by changing the database recovery model to SIMPLE.
ALTER DATABASE AdventureWorks2012
SET RECOVERY SIMPLE;
GO
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE (AdventureWorks2012_Log, 1);
GO
-- Reset the database recovery model.
ALTER DATABASE AdventureWorks2012
SET RECOVERY FULL;
GO

Auguy
Sylvania/Toledo Ohio

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close