Whenever you will try to truncate or delete the row in database at that time you can see that the database size will not reflected automatically .So how can we do that ? actually it is not complicated as much that it sound . so here i am share some tips with you that might be help you . first of all before we start you must have to know that what is the difference between Truncate and delete command in sql server .

Stackbuddy

SQL Delete Statement

The DELETE Statement is used to delete rows from a table.

The WHERE clause in the sql delete command is optional and it identifies the rows in the column that gets deleted.

Example :

To delete an employee with id 10 from the employee table, the sql delete query would be like,

To delete all the rows from the exam table, the query would be like,

SQL TRUNCATE Statement

The SQL TRUNCATE command is used to delete all the rows from the table and free the space containing the table.

Syntax to TRUNCATE a table:

Example :

Difference between Delete and Truncate Command

DELETE handles rows chosen with a WHERE statement. Its use is part of the discipline of running production applications. For example, you might DELETE all rows that have been marked “complete” more than a month ago.

TRUNCATE rapidly removes all rows from a table while maintaining the table definition. (Row by row DELETE can take time, especially for tables with lots of keys.) It comes in handy for such things as log tables that start out empty for each week’s production. It has the convenient side effect of resetting the indexes and releasing unused disk storage. I have used TRUNCATE to wipe out the contents of a log table that used to contain millions of rows, to switch to an operational discipline where it only contains a weeks’ worth of rows.

How to reduce the database size after delete or truncate ?

Just follow the below steps .
1) Connect with your sql server with appropriate credentials.

2) Select your database and perform the right click operation on that .

3) Now select the following item  Task => Shrink => Database ,below are the screen shot for the same .

Untitled

4) Select the database option and Done . Now you can check you database size it will decrease .

If you still found any issue the please leave your comment at below.    🙂 🙂




Kalpesh Sharma
StackBuddy from Kalpesh Sharma aims to help out bloggers & developer to become successful online. Stackbuddy is focus on several things like blogging tips, search engine optimization tips, make money online tips , SEO tips, job updates , programing tips and internet marketing tips for your online success.
Reduce database size after truncate or delete in MS SQL was last modified: July 7th, 2015 by Kalpesh Sharma
Join StackBuddy Newsletter

Join StackBuddy Newsletter

Get Free Weekly Updates Via Email About Blogging Tips, SEO , Affiliate Marketing, Make Money Online & News from Stackbuddy.

You have Successfully Subscribed!

Leave a Reply

Your email address will not be published. Required fields are marked *

Join The StackBuddy Club !

Join The StackBuddy Club !

Enter your email address to subscribe to this blog & receive notifications of new posts by email

You have Successfully Subscribed!

Share This

Share this post with your friends!