SQL SERVER实用经验技巧集 [一]
2007-11-11 04:08:19 来源:WEB开发网
核心提示: ·精华推荐:Excel实用技巧九则·绝对好使的二十条电脑超级技巧·快乐小技巧:在宿舍里也能自娱自乐·高手支招 Excel 2003 的另类技巧·路径工具勾图、去底的方法技巧·娱乐常用技巧:画框中探出头来的美女·Excel
·精华推荐:Excel实用技巧九则
·绝对好使的二十条电脑超级技巧
·快乐小技巧:在宿舍里也能自娱自乐
·高手支招 Excel 2003 的另类技巧
·路径工具勾图、去底的方法技巧
·娱乐常用技巧:画框中探出头来的美女
·Excel实用操作技巧九则
·电脑常用知识与应用小技巧
·Excel大量数据同时输入的技巧
·Excel XP实用技巧10例
| -- Setup / initialize DECLARE @OriginalSize int SELECT @OriginalSize = size FROM sysfiles WHERE name = @LogicalFileName SELECT 'Original Size of ' + db_name() + ' LOG is ' + CONVERT(VARCHAR(30),@OriginalSize) + ' 8K pages or ' + CONVERT(VARCHAR(30),(@OriginalSize*8/1024)) + 'MB' FROM sysfiles WHERE name = @LogicalFileName CREATE TABLE DummyTrans (DummyColumn char (8000) not null) |
| DECLARE @Counter INT, @StartTime DATETIME, @TruncLog VARCHAR(255) SELECT @StartTime = GETDATE(), @TruncLog = 'BACKUP LOG ' + db_name() + ' WITH TRUNCATE_ONLY' DBCC SHRINKFILE (@LogicalFileName, @NewSize) EXEC (@TruncLog) -- Wrap the log if necessary. WHILE @MaxMinutes > DATEDIFF (mi, @StartTime, GETDATE()) -- time has not expired AND @OriginalSize = (SELECT size FROM sysfiles WHERE name = @LogicalFileName) AND (@OriginalSize * 8 /1024) > @NewSize BEGIN -- Outer loop. SELECT @Counter = 0 WHILE ((@Counter < @OriginalSize / 16) AND (@Counter < 50000)) BEGIN -- update INSERT DummyTrans VALUES ('Fill Log') DELETE DummyTrans SELECT @Counter = @Counter + 1 END EXEC (@TruncLog) END SELECT 'Final Size of ' + db_name() + ' LOG is ' + CONVERT(VARCHAR(30),size) + ' 8K pages or ' + CONVERT(VARCHAR(30),(size*8/1024)) + 'MB' FROM sysfiles WHERE name = @LogicalFileName DROP TABLE DummyTrans SET NOCOUNT OFF |
[未完待续]
赞助商链接