Shrink a Table

%3CLINGO-SUB%20id%3D%22lingo-sub-2712217%22%20slang%3D%22en-US%22%3EShrink%20a%20Table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2712217%22%20slang%3D%22en-US%22%3E%3CP%3EIs%20it%20possible%20to%20shrink%20or%20compress%20the%20table%20after%20deleting%20some%20of%20records.%20If%20yes%2C%20could%20some%20one%20provide%20the%20suitable%20query%20or%20procedure%20to%20shrink%20the%20table.%3C%2FP%3E%3CP%3EWhich%20is%20the%20best%20practice%2C%20to%20shrink%20selected%20table%20or%20shrinking%20entire%20database.%3F%3C%2FP%3E%3CP%3EWill%20the%20data%20can%20be%20logged%20to%20table%20during%20shrinking%20process%3F%3C%2FP%3E%3CP%3EThank%20you%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2712308%22%20slang%3D%22en-US%22%3ERe%3A%20Shrink%20a%20Table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2712308%22%20slang%3D%22en-US%22%3EThe%20main%20intention%20is%2C%20I%20want%20to%20save%20some%20memory%20after%20deleting%20records%20of%20a%20table.%20So%20I%20need%20method%20and%20procedure%20to%20save%20memory%20after%20deleting%20records%20from%20table.%3C%2FLINGO-BODY%3E
New 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