{"id":487,"date":"2012-08-24T10:43:17","date_gmt":"2012-08-24T01:43:17","guid":{"rendered":"http:\/\/auctionpro.co.kr\/WPress\/?p=487"},"modified":"2013-04-04T02:55:37","modified_gmt":"2013-04-03T17:55:37","slug":"%ed%8a%b8%eb%9e%9c%ec%a0%9d%ec%85%98-%eb%a1%9c%ea%b7%b8-%ec%a4%84%ec%9d%b4%ea%b8%b0","status":"publish","type":"post","link":"https:\/\/www.auctionpro.co.kr\/?p=487","title":{"rendered":"\ud2b8\ub79c\uc81d\uc158 \ub85c\uadf8 \uc904\uc774\uae30"},"content":{"rendered":"<p><a href=\"https:\/\/auctionpro.co.kr\/wp-content\/uploads\/2012\/08\/DBLog2.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-491\" title=\"DBLog\" src=\"https:\/\/auctionpro.co.kr\/wp-content\/uploads\/2012\/08\/DBLog2.gif\" alt=\"\" width=\"718\" height=\"303\" srcset=\"https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2012\/08\/DBLog2.gif 718w, https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2012\/08\/DBLog2-300x126.gif 300w\" sizes=\"auto, (max-width: 718px) 100vw, 718px\" \/><\/a><br \/>\nUSE <strong>MYDB<\/strong><br \/>\nDBCC SHRINKFILE(MYDB_log,2)<br \/>\nBACKUP LOG MYDB\u00a0WITH TRUNCATE_ONLY<br \/>\nDBCC SHRINKFILE(MYDB_log,2)<\/p>\n<p>&#8211;SQL 7\uc5d0\uc11c \ud2b8\ub79c\uc81d\uc158 \ub85c\uadf8 \uacf5\uac04 \u00a0\uc904\uc774\uae30<\/p>\n<p>SET NOCOUNT ON<br \/>\nDECLARE @LogicalFileName sysname,<br \/>\n@MaxMinutes INT,<br \/>\n@NewSize INT<\/p>\n<p>&#8212; *** MAKE SURE TO CHANGE THE NEXT 3 LINES WITH YOUR CRITERIA. ***<br \/>\nUSE <strong>MYDB<\/strong>\u00a0\u00a0&#8212; This is the name of the database<br \/>\n&#8211;for which the log will be shrunk.<br \/>\nSELECT @LogicalFileName = &#8216;<strong>MYDB<\/strong>_Log&#8217;, &#8212; Use sp_helpfile to identify the logical file name that you want to shrink.<br \/>\n@MaxMinutes = 10, &#8212; Limit on time allowed to wrap log.<br \/>\n@NewSize = 100 &#8212; in MB<\/p>\n<p>&#8212; Setup \/ initialize<br \/>\nDECLARE @OriginalSize int<br \/>\nSELECT @OriginalSize = size &#8212; in 8K pages<br \/>\nFROM sysfiles<br \/>\nWHERE name = @LogicalFileName<br \/>\nSELECT &#8216;Original Size of &#8216; + db_name() + &#8216; LOG is &#8216; +<br \/>\nCONVERT(VARCHAR(30),@OriginalSize) + &#8216; 8K pages or &#8216; +<br \/>\nCONVERT(VARCHAR(30),(@OriginalSize*8\/1024)) + &#8216;MB&#8217;<br \/>\nFROM sysfiles<br \/>\nWHERE name = @LogicalFileName<br \/>\nCREATE TABLE DummyTrans<br \/>\n(DummyColumn char (8000) not null)<br \/>\n&#8212; Wrap log and truncate it.<br \/>\nDECLARE @Counter INT,<br \/>\n@StartTime DATETIME,<br \/>\n@TruncLog VARCHAR(255)<br \/>\nSELECT @StartTime = GETDATE(),<br \/>\n@TruncLog = &#8216;BACKUP LOG &#8216; + db_name() + &#8216; WITH TRUNCATE_ONLY&#8217;<br \/>\n&#8212; Try an initial shrink.<br \/>\nDBCC SHRINKFILE (@LogicalFileName, @NewSize)<br \/>\nEXEC (@TruncLog)<br \/>\n&#8212; Wrap the log if necessary.<br \/>\nWHILE @MaxMinutes &gt; DATEDIFF (mi, @StartTime, GETDATE()) &#8212; time has not expired<br \/>\nAND @OriginalSize = (SELECT size FROM sysfiles WHERE name = @LogicalFileName) &#8212; the log has not shrunk<br \/>\nAND (@OriginalSize * 8 \/1024) &gt; @NewSize &#8212; The value passed in for new size is smaller than the current size.<br \/>\nBEGIN &#8212; Outer loop.<br \/>\nSELECT @Counter = 0<br \/>\nWHILE ((@Counter &lt; @OriginalSize \/ 16) AND (@Counter &lt; 50000))<br \/>\nBEGIN &#8212; update<br \/>\nINSERT DummyTrans VALUES (&#8216;Fill Log&#8217;) &#8212; Because it is a char field it inserts 8000 bytes.<br \/>\nDELETE DummyTrans<br \/>\nSELECT @Counter = @Counter + 1<br \/>\nEND &#8212; update<br \/>\nEXEC (@TruncLog) &#8212; See if a trunc of the log shrinks it.<br \/>\nEND &#8212; outer loop<br \/>\nSELECT &#8216;Final Size of &#8216; + db_name() + &#8216; LOG is &#8216; +<br \/>\nCONVERT(VARCHAR(30),size) + &#8216; 8K pages or &#8216; +<br \/>\nCONVERT(VARCHAR(30),(size*8\/1024)) + &#8216;MB&#8217;<br \/>\nFROM sysfiles<br \/>\nWHERE name = @LogicalFileName<br \/>\nDROP TABLE DummyTrans<br \/>\nPRINT &#8216;*** Perform a full database backup ***&#8217;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>USE MYDB DBCC SHRINKFILE(MYDB_log,2) BACKUP LOG MYDB\u00a0WITH TRUNCATE_ONLY DBCC SHRINKFILE(MYDB_log,2) &#8211;SQL 7\uc5d0\uc11c \ud2b8\ub79c\uc81d\uc158 \ub85c\uadf8 \uacf5\uac04 \u00a0\uc904\uc774\uae30 SET NOCOUNT ON DECLARE @LogicalFileName sysname, @MaxMinutes INT, @NewSize <a class=\"mh-excerpt-more\" href=\"https:\/\/www.auctionpro.co.kr\/?p=487\" title=\"\ud2b8\ub79c\uc81d\uc158 \ub85c\uadf8 \uc904\uc774\uae30\">[&#8230;]<\/a><\/p>\n<\/div>","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-487","post","type-post","status-publish","format-standard","hentry","category-auctonpro-is"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.auctionpro.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/487","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.auctionpro.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.auctionpro.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.auctionpro.co.kr\/index.php?rest_route=\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/www.auctionpro.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=487"}],"version-history":[{"count":0,"href":"https:\/\/www.auctionpro.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/487\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.auctionpro.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=487"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.auctionpro.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=487"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.auctionpro.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=487"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}