HOW TO SHRINK ALL LOG FILES FOR SQL SERVER? – SCRIPT TO SHRINK
ALL LOG FILES
DECLARE
@Script
VARCHAR
(
MAX
);
SET
@Script =
''
;
SELECT
@Script = @Script +
'USE ['
+ d.
name
+
']; CHECKPOINT; DBCC SHRINKFILE ('
+f.
name
+
');'
FROM
sys.master_files f
INNER
JOIN
sys.databases d
ON
d.database_id = f.database_id
WHERE
f.type = 1
AND
d.database_id > 4
-- AND d.name = 'SpecificDabasename'-- in case you want particular db log files to be shrinked
SELECT
@Script
Script EXEC
(@Script )
Execute it in masters database.
thanks,
No comments:
Post a Comment