How to clean Log table?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
6 years ago
When I am clicking "Clear Log", logs are deleting, but the size of DB does not decrease. How to solve the problem?
6 years ago
Well, the title of this topic and post are far away!! but I'm trying to address the problem.  

Deleting rows in a database will not decrease the actual database file size. While you deleting record from table DB server reserves that space and not considering as a free space.

One way is shrink the database to reduce size of it, but you should not go for it, except if its really needed.

Here is good read: SQL Server database size didn't decrease after deleting large number of rows.
6 years ago
Divyang is right. Then you have to shrink database. You can also do it manually the following way (without increasing database size):

TRUNCATE TABLE [Log]
GO
6 years ago
Note that TRUNCATE does not free disk space any more than DELETE does.  Unless you had a massive Log, you should not be concerned as the space will be reused for additional data eventually.  You can read here if you really think you want to free the space.
6 years ago
New York wrote:
Note that TRUNCATE does not free disk space any more than DELETE does.

That's right. TRUNCATE doesn't recover space. But if I'm not wrong, TRUNCATE doesn't use transactional log. Hence no additional space will be used to save transation history (compared to DELETE command that will reduce free space in transactional log)
6 years ago
You can shrink database after truncate command has been executed.

https://docs.microsoft.com/en-us/sql/relational-databases/databases/shrink-a-database
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.