We help IT Professionals succeed at work.

Truncate table from SQL Server 2008

170 Views
Last Modified: 2019-02-26
Hi,

In current production environment, we have requirement to truncate approx 860 million records from table in MS SQL server 2008. Please advise the best option to truncate table without impacting end users within production environment.


Regards
Tom
Comment
Watch Question

Raja Jegan RSQL Server DBA & Architect, EE Solution Guide
CERTIFIED EXPERT
Awarded 2009
Distinguished Expert 2019

Commented:
Simple, if the table doesn't have any Foreign keys, then TRUNCATE TABLE should truncate your table without any issues.
TRUNCATE TABLE ur_Table_name

Open in new window

Author

Commented:
Thank you for the update.

If there is requirement to delete in batches for eg year wise, are there any script available  and also take care of reducing transaction logging while deleting in batches.


Regards
Raja Jegan RSQL Server DBA & Architect, EE Solution Guide
CERTIFIED EXPERT
Awarded 2009
Distinguished Expert 2019

Commented:
If you want to DELETE in batches, then it will be logged in Transaction logs and the amount of logging can't be reduced whatever your Recovery model is in..
If you want to reduce the transaction log file to grow to a huge size while deleting in batches, then you can do the below things:
1. Take Log backups more frequently.
2. Change your Recovery model to simple(Not recommended as it would break Log chains).
ste5anSenior Developer
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Senior Manager
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Thank you All for the solutions recommended.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.