{"id":91,"date":"2009-07-28T10:54:11","date_gmt":"2009-07-28T14:54:11","guid":{"rendered":"http:\/\/dbtricks.com\/?p=91"},"modified":"2009-08-04T20:40:04","modified_gmt":"2009-08-05T00:40:04","slug":"91","status":"publish","type":"post","link":"https:\/\/dbtricks.com\/?p=91","title":{"rendered":"Adding a Transaction Log at runtime to prevent it from running out of space"},"content":{"rendered":"<p>sometimes, when running a big transaction, <a href=\"http:\/\/dbtricks.com\/?p=14\" target=\"_blank\">the transaction log can become full or simply grow to a huge size<\/a> . while you can sometimes free some space using &#8220;<strong>backup log db-name with truncate_only<\/strong>&#8221; and trying to shrink the DB using SQL Management studio. <P><br \/>\nThe process is described in the above link but basically it is: <strong>right click on the Database name -&gt;tasks-&gt;shrink-&gt;files and choosing the log file.<\/strong><br \/>\nThis will shrink the db if there is free space in the transaction log but it can only serve as a temporary solution.<P><\/p>\n<p>If the transaction is still running and you are afraid that the hard drive will run out of disk space, a better solution would be to create another transaction log on a different drive. This will solve the disk space issue and might even improve performance.<br \/>\nTo create another transaction log file\u00a0 using the SQL Server Management Studio:<\/p>\n<ul>\n<strong>1)<\/strong> Expand the DataBases node and choose your Database<br \/>\n<strong>2)<\/strong> Right Click your Database and click Properties.<br \/>\n<strong>3)<\/strong> Select the Files Page<br \/>\n<strong>4)<\/strong> CLick ADD and Navigate to te Database files grid.<br \/>\n<strong>5)<\/strong> Enter a name for the new log file. This name must be unique within the database.<br \/>\n<strong>6)<\/strong> Select the Log file type<br \/>\n<strong>7)<\/strong> select initial size, growth method (auto Growth, fixed Increments or percent). you can also set a maximum size. Set up the path to the new file and file name and Click OK\n<\/ul>\n<p>In Some cases, the file name column might be disabled when adding a log file using the Sql Server Mangment Studio while the transaction is still runing.<br \/>\nIn this case you can add the file manually using a query.<br \/>\nOpen a query editor and type:<br \/>\n<P><br \/>\n<strong>USE master<\/p>\n<p>GO<\/p>\n<p>ALTER DATABASE db-name<\/p>\n<p>ADD LOG FILE<\/p>\n<p>( NAME = addedlog,<\/p>\n<p>FILENAME = &#8216;I:addedlog.ldf&#8217;,<\/p>\n<p>SIZE = 1000MB,<\/p>\n<p>&#8212; MAXSIZE = 10000MB,<\/p>\n<p>FILEGROWTH = 10MB)<\/p>\n<p>GO<\/strong><\/p>\n<p>There are better<a href=\"http:\/\/dbtricks.com\/?p=44\" target=\"_blank\"> ways to avoid the Transaction log is full<\/a> situation and this should be prevented in the the first place by the code but if you got no access to it, this might be a good solution.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>sometimes, when running a big transaction, the transaction log can become full or simply grow to a huge size . while you can sometimes free some space using &#8220;backup log db-name with truncate_only&#8221; and trying to shrink the DB using SQL Management studio. The process is described in the above link but basically it is: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-91","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/dbtricks.com\/index.php?rest_route=\/wp\/v2\/posts\/91","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dbtricks.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dbtricks.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dbtricks.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dbtricks.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=91"}],"version-history":[{"count":19,"href":"https:\/\/dbtricks.com\/index.php?rest_route=\/wp\/v2\/posts\/91\/revisions"}],"predecessor-version":[{"id":115,"href":"https:\/\/dbtricks.com\/index.php?rest_route=\/wp\/v2\/posts\/91\/revisions\/115"}],"wp:attachment":[{"href":"https:\/\/dbtricks.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=91"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dbtricks.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=91"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dbtricks.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=91"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}