先確認資料庫的邏輯名稱 Select * from sys.database_files 後續以Northwind為例說明: SET NOCOUNT ON DECLARE @LogicalFileName sysname, @MaxMinutes INT , @NewSize INT -- *** MAKE SURE TO CHANGE THE NEXT 4 LINES WITH YOUR CRITERIA. *** USE Northwind -- This is the name of the database -- for which the log will be shrunk. SELECT @LogicalFileName = 'Northwind_Log' , -- Use sp_helpfile to -- identify the logical file -- name that you want to shrink. @MaxMinutes = 10 , -- Limit on time allowed to wrap log. @NewSize = 10 -- in MB -- Setup / initialize DECLARE @OriginalSize int SELECT @OriginalSize = size -- in 8K pages FROM sysfiles WHERE name = @LogicalFileName SELECT 'Original Size of ' + db_name() + ' LOG is ' + CONVERT ( VARCHAR ( 30 ),@OriginalSize) + ' 8K pages or ' +