Search EggHeadCafe's Job Board
EggHeadCafe Silverlight WPF ASP.NET VB.NET C# Excel SQL Server SharePoint
search
MicrosoftArticlesForumsFAQs
C# .NET
VB.NET
Visual Studio .NET
ADO.NET
Xml / Xslt
VB 6.0
.NET CF
GDI+
LINQ
Deployment
Security
FoxPro
Silverlight / WPF
Entity Framework
RIA Services

WebArticlesForumsFAQs
JavaScript
ASP
ASP.NET
WCF

DatabasesArticlesForumsFAQs
SQL Server
Access
Oracle
MySQL
Other Databases

OfficeArticlesForumsFAQs
Excel
Word
Powerpoint
Outlook
Publisher
Money

Non-MicrosoftArticlesForumsFAQs
NHibernate
Perl
PHP
Ruby
Java
Linux / Unix
Apple
Open Source

Operating SysArticlesForumsFAQs
Windows 7
Windows Server
Windows Vista
Windows XP
Windows Update
MAC
Linux / UNIX

Server PlatformsArticlesForumsFAQs
BizTalk
Site Server
Exhange Server
IIS

Graphic DesignArticlesForumsFAQs
Macromedia Flash
Adobe PhotoShop
Expression Blend
Expression Design
Expression Web

OtherArticlesForumsFAQs
Lounge
Subversion / CVS
Ask Dr. Dotnetsky
Active Directory
Networking
Uninstall Virus
Job Openings
Product Reviews
Search Engines
Resumes

 

  View Other SQL Server Posts   Ask New Question  Ask New Question With Power Editor

How to Truncate Transaction Log in SQL2000 usin SQLDMO
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
November 0 $0.00 0
October 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 MCTS.
  Rank Winnings Points
November 0 $0.00 0
October 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
November 0 $0.00 0
October 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
November 0 $0.00 0
October 0 $0.00 0