Solved

SQL Truncate

Posted on 2013-11-15
6
312 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

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

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Suggested Solutions

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
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.

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now