Skip to content

Commit 9f798a6

Browse files
Merge pull request #33895 from dimitri-furman/dfurman/shrink
Fix truncateonly with target
2 parents ea5bcdc + 6aa580f commit 9f798a6

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

docs/t-sql/database-console-commands/dbcc-shrinkdatabase-transact-sql.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: DBCC SHRINKDATABASE shrinks the size of the data and log files in t
44
author: WilliamDAssafMSFT
55
ms.author: wiassaf
66
ms.reviewer: umajay, KevinConanMSFT, dplessMSFT, randolphwest
7-
ms.date: 01/21/2025
7+
ms.date: 04/22/2025
88
ms.service: sql
99
ms.subservice: t-sql
1010
ms.topic: reference
@@ -89,6 +89,8 @@ The database name or ID to be shrunk. 0 specifies that the current database is u
8989

9090
The percentage of free space that you want left in the database file after the shrink operation completes.
9191

92+
If *target_percent* is specified with `TRUNCATEONLY`, free space at the end of the file might not be released.
93+
9294
#### NOTRUNCATE
9395

9496
Moves assigned pages from the file's end to unassigned pages in the front of the file. This action compacts the data within the file. *target_percent* is optional. [!INCLUDE [ssazuresynapse-md](../../includes/ssazuresynapse-md.md)] doesn't support this option.
@@ -99,9 +101,9 @@ The free space at the end of the file isn't returned to the operating system, an
99101

100102
#### TRUNCATEONLY
101103

102-
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`. [!INCLUDE [ssazuresynapse-md](../../includes/ssazuresynapse-md.md)] doesn't support this option.
104+
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. [!INCLUDE [ssazuresynapse-md](../../includes/ssazuresynapse-md.md)] doesn't support this option.
103105

104-
`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](dbcc-shrinkfile-transact-sql.md).
106+
If *target_percent* is specified with `TRUNCATEONLY`, free space at the end of the file might not be released.
105107

106108
#### WITH NO_INFOMSGS
107109

docs/t-sql/database-console-commands/dbcc-shrinkfile-transact-sql.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: "DBCC SHRINKFILE shrinks the size of a database file."
44
author: WilliamDAssafMSFT
55
ms.author: wiassaf
66
ms.reviewer: umajay, dpless, randolphwest
7-
ms.date: 01/21/2025
7+
ms.date: 04/22/2025
88
ms.service: sql
99
ms.subservice: t-sql
1010
ms.topic: reference
@@ -89,6 +89,8 @@ This option isn't supported for FILESTREAM filegroup containers.
8989

9090
If specified, `DBCC SHRINKFILE` tries to shrink the file to *target_size*. Used pages in the file's area to be freed are moved to free space in the file's kept areas. For example, with a 10-MB data file, a `DBCC SHRINKFILE` operation with an `8` *target_size* moves all used pages in the file's last 2 MB into any unallocated pages in the file's first 8 MB. `DBCC SHRINKFILE` doesn't shrink a file past the needed stored data size. For example, if 7 MB of a 10-MB data file is used, a `DBCC SHRINKFILE` statement with a *target_size* of 6 shrinks the file to only 7 MB, not 6 MB.
9191

92+
If *target_size* is specified with `TRUNCATEONLY`, free space at the end of the file might not be released.
93+
9294
#### EMPTYFILE
9395

9496
Migrates all data from the specified file to other files in the *same filegroup*. In other words, `EMPTYFILE` migrates data from a specified file to other files in the same filegroup. `EMPTYFILE` assures you that no new data gets added to the file, despite this file not being read-only. You can use the [ALTER DATABASE](../../t-sql/statements/alter-database-transact-sql.md) statement to remove a file. If you use the [ALTER DATABASE](../../t-sql/statements/alter-database-transact-sql.md) statement to change file size, the read-only flag is reset, and data can be added.
@@ -109,7 +111,7 @@ This option isn't supported for FILESTREAM filegroup containers.
109111

110112
Releases all free space at the file's end to the operating system but doesn't perform any page movement inside the file. The data file is shrunk only to the last allocated extent.
111113

112-
*target_size* is ignored if specified with `TRUNCATEONLY`.
114+
If *target_size* is specified with `TRUNCATEONLY`, free space at the end of the file might not be released.
113115

114116
The `TRUNCATEONLY` option doesn't move information in the log, but does remove inactive VLFs from the end of the log file. This option isn't supported for FILESTREAM filegroup containers.
115117

0 commit comments

Comments
 (0)