1
0
mirror of https://github.com/alex-bochkov/ssms-addin.git synced 2025-11-23 22:04:53 +02:00

Update shrink-data-files-incrementally.sql

This commit is contained in:
Alex Bochkov
2020-03-05 11:48:38 -08:00
committed by GitHub
parent e9c5af75f5
commit f98d732e1b

View File

@@ -1,10 +1,10 @@
-- Enter the file name you want to shrink and target file size
-- File will be shrinked in a loop by one gigabyte at a time
DECLARE @FileName VARCHAR(100) = 'file_name';
DECLARE @DesiredSize INT = 30000;
DECLARE @DesiredSize BIGINT = 30000;
DECLARE @CurrentSize INT;
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
WHILE (@CurrentSize > @DesiredSize)
BEGIN