C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » Databases »

The Microsoft SQL Server Transaction Log


Posted Date: 23 May 2006    Resource Type: Articles    Category: Databases
Author: ANITA MARY JOSEPHMember Level: Gold    
Rating: 1 out of 5Points: 10




Introduction

Every SQL Server database has at least two files associated with it:

- The Database File (.MDF) and
- The Transaction Log file (.LDF)

Now, Having a firm grasp of the Transaction log is important for both - the database developers as well as the administrators; hence the Transaction log file would be the prime focus of this article.


Transaction Log

The transaction log can be defined as a fundamental component of the database management system to which the SQL Server writes all transactions before writing them to the database.
By having every database change recorded in the Log file, we can assure ourselves that the data can be restored even if a malfunction occurs.

When creating the database, the location of the SQL Server transaction log has to be specified.
Right Click your database in the Enterprise Manager, and Move to properties. You’ll find a Tag named ‘Transaction Log’, that’s where you can set the Initial Size and other file properties of the Transaction Log such as the File Growth Rate and the File Size.

File Growth : It's the rate at which the transaction log files grow. It can be specified as megabytes or percentage. The File Growth property tells SQL Server that when the transaction log reaches a specified point it should automatically grow the file by the amount of growth specified in order to accommodate future transactions.

File Size: Here's the option to set the maximum size of the transaction log file. You've got two choices. It can be set to unrestricted file growth or to the specified amount of megaBYTES.

The Information recorded in the transaction log would contain the following:
• the beginning time of each transaction
• the changes made to the data and
• the actual commit or rollback of each transaction

With this information on hand the Microsoft SQL Server can accomplish data integrity to ensure that consistent data is maintained in the database.

Wondering when this log file is used???
Well, The transaction log is used each time the SQL Server is restarted, when the transactions are rolled back, as well as when the database is to be restored.

If your data tends to change constantly, you’ll have to actively monitor the size of the log file, because the transaction log of the database will keep growing each time a change in the database occurs.
Hence the growth must be planned for to handle the growth accordingly else an error message will be thrown on your screen stating that the transaction log is full!

The Microsoft SQL Server guarantees that all the log records before the check point will be written to the disk safely. The check point I’ve mentioned here represents the point at which the startup recovery must start rolling transactions forward.

In case you need to shrink the Log file, It can be done by executing the DBCC SHRINKDATABASE statement against the owning database, Here’s how you do it:


DBCC SHRINKDATABASE (DatabaseName, 10)
GO

The above command decreases the size of the data and log files in the mentioned Database to allow 10 percent of free space.

Another point to note here is – All operations are NOT always logged. Large Operations such as the CREATE INDEX, SELECT INTO and BULK load operations may not be recorded in the log to make sure the space available in the log file doesn’t get used up.


The Transaction Log file is vital when it comes to database management!


Well that’s not all,
Lets Move on to one of SQL’s interesting built in feature: ‘The Data Recovery Model’, Click Here.







Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Package Restartablity using checkpoints
Previous Resource: The Microsoft SQL Server Database Recovery Model
Return to Discussion Resource Index
Post New Resource
Category: Databases


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use