logo

How to Truncate Transaction Log in SQL2000 usin SQLDMO (SQL Server)
Noman Nasir posted at Wednesday, December 20, 2006 2:40 AM

My Data Base log became bigger enough to 20GB I want to trancate the log using SQLDMO
I write the following code. Code is executed without error but log file size remains same.
Plz Help

Dim mServer As New SQLDMO.SQLServer2
mServer.Connect "ServerName", "UID", "PWD"
mServer.Databases.Item("DBName").TransactionLog.Truncate
Reply    Reply Using Power Editor
  Rank Winnings Points
February 0 $0.00 0
January 0 $0.00 0
Very easy way to truncate Transaction log
K Pravin Kumar Reddy provided a rated reply to Noman Nasir on Wednesday, December 20, 2006 4:17 AM

in SQL Server 2000

backup log [database name] with truncate_only
(run this in query analyzer)

(open enterprise manager and expand the server tree)
--right click on the database
--all task
--shrink database
--bottom button (on right side of form) for files
--select sql log file (default is data file so make sure and change it)
--click ok

the log size of my main database was 67 gigs. I ran this and it shrinked my database size from 67 gigs to 50 megs (49 of which is the data file)

reference

http://forums.databasejournal.com/archive/index.php/t-40824.html

Truncate SQL Server Transaction Log

http://www.codeproject.com/cs/database/ClearTransactionLog.asp

Reply    Reply Using Power Editor
K Praveen Kumar Reddy MCPDEA.
  Rank Winnings Points
February 0 $0.00 0
January 0 $0.00 0

Thanx
Noman Nasir replied to K Pravin Kumar Reddy on Wednesday, December 20, 2006 11:51 PM

Thanx a lot!
Reply    Reply Using Power Editor
  Rank Winnings Points
February 0 $0.00 0
January 0 $0.00 0

use DBCC
Saurabh Kaushik provided a rated reply to Noman Nasir on Friday, December 29, 2006 10:17 AM

DBCC statememnts act as Database Console commands. You can use the below listed queries, sprcifically the DBCC ones to shrink your transaction log.

-- To GET the name of the log and data files
select name from dbo.sysfiles

-- SEE the active transactions as well as the File ID
dbcc loginfo('db_Name')

-- Mark transactions inactive so that they can be truncated later
-- Suppose file ID is 2

DBCC SHRINKFILE (2)
-- Backup the log file and truncate the inactive entries
BACKUP LOG [db_name] WITH TRUNCATE_ONLY
-- Run Shrinkfile again for maintainence.
DBCC SHRINKFILE (2)

You can create a stored procedure out of the last 3 statements and schedule it as a job on your server than can run overnight and ensure that the transaction log file size does not get out of hand.

Hope this helps.

Reply    Reply Using Power Editor
  Rank Winnings Points
February 0 $0.00 0
January 0 $0.00 0


Didn't Find The Answer You Were Looking For?

EggHeadCafe has experts online right now that may know the answer to your question.  We pay them a bonus for answering as many questions as they can.  So, why not help them and yourself by becoming a member (free) and ask them your question right now?
Ask Question In Live Forum

If you have an OpenID and do not want to become a member of the EggHeadCafe forum, you can also sign on to Chat Chaos and post your question to our real time Silverlight chat application.
Ask Question In Chat Chaos










  $1000 Contest    [)ia6l0 iii - $228  |  Jonathan VH - $161  |  Huggy Bear - $135  |  F Cali - $95  |  egg egg - $94  |  more Advertise  |  Privacy  |   (c) 2010