?
Solved

SQL Truncate

Posted on 2013-11-15
6
Medium Priority
?
332 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

 

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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

I have a large data set and a SSIS package. How can I load this file in multi threading?
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

765 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