Solved

SQL Truncate

Posted on 2013-11-15
6
316 Views
Last Modified: 2013-11-21
I need to Truncate SQL database both MDB and LDB. How is this done and what are the risks?
I was told a full SQL backup should be done prior to performing this task.
Is there a way to determine when the last Full backup was done as well?
0
Comment
Question by:sullend
6 Comments
 
LVL 21

Expert Comment

by:oleggold
ID: 39651450
yes,db log , and yes,full backup required anyways before truncating
0
 

Author Comment

by:sullend
ID: 39651491
Do I have to detach in order to truncate?
0
 
LVL 2

Expert Comment

by:aheddell
ID: 39651542
No.  Won't work if you detach.

You can in theory truncate the log using the NO_LOG parameter on the BACKUP command.  Its easier to just to do the backup though.  

I assume this is a one off operation?  Is so, the easiest way to determine the last backup is in the SQL Server Management Studio, right-click on the database and select properties.  This data is held in the msdb..backupset table

Cheers

Alex
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 

Author Comment

by:sullend
ID: 39651600
Just found out the recovery model is SIMPLE, so BACKUP LOG will no work  At this point I just need a safe way to truncate the log file. Suggestions?  

Please be specific as possible I am not a SQL admin at any level...
0
 
LVL 15

Expert Comment

by:jorge_toriz
ID: 39651672
You don´t need to truncate the log file when your database is on SIMPLE recovery model, the file is always truncated
0
 
LVL 2

Accepted Solution

by:
aheddell earned 500 total points
ID: 39656099
Do you mean you want to Shrink the file?  If so, you need to use DBCC SHRINKDATABASE or DBCC SHRINKFILE.  Or do it through the Management Studio
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

777 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