SQL Flow Field Guide

DBCC SHRINKFILE

Catalog support for SQL Server 2022 (16.x) and 2025 (17.x)

DBCC SHRINKFILE: administrative check or maintenance

What changes

Input
database, table, index, cache or server state named in the command
Output or change
messages or result sets; maintenance forms change storage, caches or metadata

Syntax at a glance

DBCC SHRINKFILE ( { file_name | file_id } { [ , EMPTYFILE ] | [ [ , target_size ] [ , { NOTRUNCATE | TRUNCATEONLY } ] ] } ) [ WITH { [ WAIT_AT_LOW_PRIORITY [ ( <wait_at_low_priority_option_list> ) ] ] [ , NO_INFOMSGS ] } ]

Work example

One database file has unused space that an approved one-time task may release.

Check allocated pages, file growth settings, workload, and backup impact before selecting the file.

Check your work The file retains required capacity and no recurring shrink-and-grow cycle begins.

Open Microsoft Learn for full syntax, permissions, and details for your version.