We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e9c5af7 commit f98d732Copy full SHA for f98d732
QueryTemplates/Common Scripts/shrink-data-files-incrementally.sql
@@ -1,10 +1,10 @@
1
-- Enter the file name you want to shrink and target file size
2
-- File will be shrinked in a loop by one gigabyte at a time
3
DECLARE @FileName VARCHAR(100) = 'file_name';
4
-DECLARE @DesiredSize INT = 30000;
+DECLARE @DesiredSize BIGINT = 30000;
5
6
-DECLARE @CurrentSize INT;
7
-SELECT @CurrentSize = ROUND(size * 8 / 1024, -3) FROM sys.database_files WHERE name = @FileName
+DECLARE @CurrentSize BIGINT;
+SELECT @CurrentSize = ROUND(CAST(size AS BIGINT) * 8 / 1024, -3) FROM sys.database_files WHERE name = @FileName
8
9
WHILE (@CurrentSize > @DesiredSize)
10
BEGIN
0 commit comments