A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
The next step is to identify whether Data is waiting on a transaction or contains an unmovable allocation near its physical end, because total free space alone does not guarantee that SQL Server can truncate the end of the file.
1. Establish the attainable size
Run this in xyz; it is diagnostic and does not initiate another shrink:
USE xyz;
GO
SELECT
file_id,
name,
type_desc,
size / 128.0 AS CurrentSizeMB,
FILEPROPERTY(name, 'SpaceUsed') / 128.0 AS UsedSpaceMB,
(size - FILEPROPERTY(name, 'SpaceUsed')) / 128.0 AS FreeSpaceMB,
growth,
is_percent_growth
FROM sys.database_files
WHERE name = N'Data';
DBCC SHRINKFILE moves allocated pages from the area being removed into free space below the target. TRUNCATEONLY does not move pages and can release space only after the last allocated extent; NOTRUNCATE moves pages but deliberately leaves the physical file unchanged.^1^
Do not target exactly the reported 664 GB. SQL Server cannot shrink below the storage required for allocated pages, and operational headroom is needed to avoid immediate autogrowth.
2. Determine whether the operation is blocked
While shrink is running, locate its session and inspect its current wait:
SELECT
r.session_id,
r.status,
r.command,
r.wait_type,
r.wait_time,
r.wait_resource,
r.blocking_session_id,
r.percent_complete,
r.total_elapsed_time
FROM sys.dm_exec_requests AS r
WHERE r.database_id = DB_ID(N'xyz')
OR r.command LIKE N'DbccFilesCompact%';
Compare wait_type, wait_time, and wait_resource across several samples. A changing or resetting wait indicates progress; a persistent blocking session identifies the next investigation point.^2^
Also search the SQL Server error log for message 5203. That message means DBCC SHRINKFILE is waiting for a row-versioning/snapshot transaction. Identify such transactions with:
USE xyz;
GO
SELECT
session_id,
transaction_sequence_num,
first_snapshot_sequence_num,
elapsed_time_seconds
FROM sys.dm_tran_active_snapshot_database_transactions
ORDER BY elapsed_time_seconds DESC;
The supported choices are to let the blocking transaction finish, end that transaction after assessing application impact, or cancel shrink; completed shrink work is retained.^1^
IAM-page locking can also stop progress: shrink needs an Sch-M lock while queries can hold Sch-S locks. On SQL Server 2022 or later, WAIT_AT_LOW_PRIORITY reduces interference with normal queries, but it can time out after one minute. Do not use ABORT_AFTER_WAIT = BLOCKERS without change approval because it terminates blocking user transactions and requires ALTER ANY CONNECTION or KILL DATABASE CONNECTION permission.^3^
3. Identify the object owning a reported page
If error 49516 or another shrink message reports a file ID and page ID, map that page to its object. On SQL Server 2019 or later:
USE xyz;
GO
SELECT
OBJECT_SCHEMA_NAME(pg.object_id) AS schema_name,
OBJECT_NAME(pg.object_id) AS object_name,
i.name AS index_name,
p.partition_number
FROM sys.dm_db_page_info(DB_ID(), <file_id>, <page_id>, DEFAULT) AS pg
JOIN sys.indexes AS i
ON i.object_id = pg.object_id AND i.index_id = pg.index_id
JOIN sys.partitions AS p
ON p.partition_id = pg.partition_id;
sys.dm_db_page_info returns the owning object, index, and partition from the page header and is supported beginning with SQL Server 2019.^4^
For allocation consistency—not merely placement—run during a suitable maintenance window:
DBCC CHECKALLOC (N'xyz') WITH NO_INFOMSGS, ALL_ERRORMSGS;
If errors are reported, restore from a known-good backup rather than immediately using repair; repair can delete pages and data.^5^
4. Check version-specific immovable structures
Confirm the exact SQL Server version and build, then inspect whether the end-of-file object uses columnstore and LOB columns:
SELECT @@VERSION;
SELECT s.name, o.name, i.name, i.type_desc
FROM sys.indexes AS i
JOIN sys.objects AS o ON o.object_id = i.object_id
JOIN sys.schemas AS s ON s.schema_id = o.schema_id
WHERE i.type_desc LIKE N'%COLUMNSTORE%';
Applicable known issues include:
- Before SQL Server 2025, LOB pages in compressed columnstore segments cannot be moved by shrink.^1^
- SQL Server 2014 nonclustered columnstore pages had a shrink defect fixed in SQL Server 2014 CU2.^6^
- Specific SQL Server 2008–2014 builds had a LOB-space reclamation defect; the documented remedies are the applicable cumulative update, rebuilding the data in a new table, or migrating it through another file.^7^
5. Safer reclamation alternatives
If Data is not the only file in its filegroup—or another sufficiently large file can be added—the documented alternative is DBCC SHRINKFILE (Data, EMPTYFILE), which migrates data to other files in the same filegroup. After validation and backup, the empty file can be removed. Ensure the destination files and storage have sufficient capacity first.^1^
For a 1.16-TB file, Microsoft also provides the ShrinkDriver PowerShell sample, which makes large-file shrink observable, resumable, and retryable. Shrinking can increase index fragmentation, so validate fragmentation and query performance afterward; avoid making shrink or AUTO_SHRINK routine maintenance.^8^
References
- DBCC SHRINKFILE (Transact-SQL)
- Understand and resolve SQL Server blocking problems
- DBCC SHRINKDATABASE (Transact-SQL)
- sys.dm_db_page_info (Transact-SQL)
- DBCC CHECKALLOC (Transact-SQL)
- KB2967198 – KORREKTUR: DBCC SHRINKDATABASE oder DBCC SHRINKFILE können keine Seiten verschieben, die zum nicht gruppierten Columnstore-Index gehören - SQL Server | Microsoft Support
- KB2967240 - FIX: Cannot reclaim unused space by using shrink operation in the table that contains a LOB column in SQL Server - SQL Server | Microsoft Support
- Shrink a file