How to truncate sql database

Hi all,

Today I want to share with you guys a simple database trick which might helps you when the sql database server disk becomes full.

Before doing this, please take the backup for your database

1. Now go to your sql database server and select your database and right click and go to properties and then select options on your right hand side and set recovery model to simple.

2. Select the database and now go to sql query and run the below command

SELECT file_id, name FROM sys.database_files;

3. Run this below command in sql query


where 2 is the id of the transaction log you get in the step 3

4. set recovery model to full again.

Thats it, you have reduced your sql database size by removing log transactions.



One thought on “How to truncate sql database

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s