reclaim unallocated space from SQL server

cygmwpex  于 2023-06-28  发布在  SQL Server
关注(0)|答案(1)|浏览(138)

I have a database in MS SQL server 2008. I have used sp_spaceused to check database size and got the following result.

So, in my DB there is 140GB unallocated space occupied by sql server. Now I want to reclaim that 140GB space for my system.

I have executed following commands to reclaim. but it doesn't work for me.

DBCC SHRINKDATABASE (DB_Name, truncateonly)

Its executed in 5 sec but only able to free 2MB at one time I have tried DBCC SHRINKDATABASE (DB_Name, notruncate) also but its executed more then 10 hrs but didn't get any result.

Please, help me to solve this issue.

Thanks in advance

zazmityj

zazmityj1#

TRUNCATEONLY Releases all free space at the end of the file to the operating system. Doesn't move any pages inside the file. The data file shrinks only to the last assigned extent. Ignores target_percent if specified with TRUNCATEONLY. Azure Synapse Analytics doesn't support this option.

DBCC SHRINKDATABASE with the TRUNCATEONLY option affects the database transaction log file only. To truncate the data file, use DBCC SHRINKFILE instead. For more information, see DBCC SHRINKFILE.

https://learn.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-shrinkfile-transact-sql?view=sql-server-ver16

相关问题