Shrink a Table

Copper Contributor

Is it possible to shrink or compress the table after deleting some of records. If yes, could some one provide the suitable query or procedure to shrink the table.

Which is the best practice, to shrink selected table or shrinking entire database.?

Will the data can be logged to table during shrinking process?

Thank you

2 Replies
The main intention is, I want to save some memory after deleting records of a table. So I need method and procedure to save memory after deleting records from table.
to save memory after deleting records from table.

@dearjitu , the used space on disk has not really an effect on the memory (RAM) for the buffer pool.

If you want to reduce the (un)used space on disk, then you can shrink the database (files) with

DBCC SHRINKDATABASE (Transact-SQL) - SQL Server | Microsoft Docs

 

Olaf