Free Newsletters:
DatabaseJournal  
DBANews
Search Database Journal:
 
HOME News MS SQL Oracle DB2 Access MySQL PostgreSQL PHP SQL Etc Scripts Links Discussion
internet.com

» HOME
» NEWS
» FEATURES
» SERIES
MS SQL
Oracle
MS Access
MySQL
DB2
» RESOURCES
Products
Scripts
Links
» DISCUSSION
» TECH JOBS

Marketplace Partners
Be a Marketplace Partner




internet.commerce
Be a Commerce Partner
KVM over IP
Boat Donations
Find Software
KVM Switches
Promotional Gifts
Auto Insurance Quote
Memory Upgrades
Compare Prices
Imprinted Gifts
Condos For Sale
Online Education
Online Shopping
Prepaid Phone Card
Web Hosting Directory




MySpace Joins eBay, Yahoo in Open Profile Push

News Corp. Unit Under Fire for Ties to Hacker

Are Non-PC Devices Hurting 'Net Innovation?

internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Linked Data Planet Conference & Expo

CA ERwin® Data Modeler Proven database design and modeling. Efficiently analyze, design and deploy effective database solutions. Whitepaper: Manage SQL Server Deployments
Try it free: CA ERwin® Data Modeler


Guide to Oracle 11g and Database Migration
Oracle Database 11g includes more features for self-management and automation, which makes it easier for customers to cost-effectively manage their data. Download this Internet.com eBook for an overview of some of the new features in 11g and for an overview of the issues you need to consider as you prepare for a database migration. »
Innovate Faster with Oracle Database 11g
Read this in-depth analysis of 56 customers, which shows significant differences between the value software vendors Oracle and SAP deliver to midsize companies. »
Oracle Business Intelligence Standard Edition One
Find out how Newport Beach, CA-based Mobilitie is shaking up the telecom industry by leveraging technology to provide an entirely different financial model for deploying, upgrading, and owning wireless and wireline network assets. »
Business Intelligence and Enterprise Performance Management: Trends for Emerging Businesses
Quickly implementing an ERP software solution can be of tremendous benefit; however, companies often struggle to balance the benefits of reducing implementation time and cost with the risks of an accelerated deployment. Read this white paper to learn about easy-to-follow best practices for achieving a successful accelerated implementation. »
Making the Case for Oracle Database on Windows
Users benefit as vendors reduce enterprise complexity and deliver integration. »

Production Manager (hands on)
Aquent
US-MA-Cambridge

Justtechjobs.com Post A Job | Post A Resume
MS SQL
March 8, 2001
Quickly Shrinking the Transaction Log
By Krishnan Kaniappan

In this article I would like to discuss about the following two things:

1) About shrinking the transaction log.
2) Different ways of taking the database offline.

1) Shrinking the log:

The following is a trick for quickly shrinking the size of the transaction log which you think has become much larger than you would like and remember that this would not work if the database has more than one log file.

You can shrink the log by using sp_detach_db and sp_attach_db system stored procedures. For more information about detaching and attaching the databases refer BOL or go to www.swynk.com/friends/krishnan/movedatabase.asp.

When you detach the database using sp_detach_db, SQL Server will know that the database was cleanly shutdown and the log file need not have to be available to attach the database again. When you attach the database again SQL Server will create a new log file for you, which will be of the minimum size.

The following are the steps to do:

a) Detach the database using sp_detach_db procedure (before that ensure no processes are using the database files.)
b) Delete the log file.
c) Attach the database again using sp_attach_db procedure.

Since you are detaching and attaching the database within the same server you will not have the problem of broken logins.

For shrinking the log consisting of one or more log files, you can find very good documentation by searching the article # Q256650 (for SQL 7.0) and article # Q272318 (for SQL 2000) in Microsoft Knowledge Base.

Note: If you use the above method to shrink the log then I would recommend you to first detach the database using sp_detach_db before attaching the database because one advantage of using sp_detach_db is that the database will be shutdown cleanly.

Although it is not necessary that the database that you are attaching be previously detached using sp_detach_db but if you are doing like this then there is no guarantee that all the dirty pages from the database were written to the disk. Again if you are attaching the database using the log file too then there should be no problem because the log file will have a record of all completed transactions and a full recovery will be done to ensure database consistency when the database is attached. (But in this case the log file size will be same which is not our objective here)

2) Tip for taking the database offline:

In SQL Server 7.0 the functionality of taking the database offline is hidden from the Enterprise Manager. So you would take the database offline using T-SQL statement i.e. using sp_dboption procedure. For example to take the 'pubs' database offline you execute the following statement

sp_dboption 'pubs','offline','true'

But before taking the database offline ensure that no processes are using the database. You can make the database online by using the 'false' keyword as

sp_dboption 'pubs','offline','false'

Whereas in SQL Server 2000 you can take the database offline by using the Enterprise Manager i.e. By right clicking on the 'database' and then choose 'All tasks' and then choose 'Take offline'.

(Or) Alter database pubs set offline (replace 'offline' with 'online' to bring the database back online)

(Or) by using sp_dboption as above.

Let me know if you have any concerns, comments or suggestions.

Tools:
Add databasejournal.com to your favorites
Add databasejournal.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed

MS SQL Archives

Five Trends for Application Development. Download Your Complimentary Report. Exclusive. Act Now.
Quest Whitepaper: Improving Oracle Database Performance Using Real-Time Visual Diagnostics
Data Sheet: IBM Information Server Blade
Flash Demo: Learn how IBM Information Server Blade is easy to manage, highly scalable and efficient.
Five Trends for Application Development & Program Management. Download Complimentary Report Now.


Latest Forum Threads
MS SQL Forum
Topic By Replies Updated
How To Transfer Access Data Records To SQL ?? ankurdjariwala 1 May 8th, 12:24 PM
problem with federated server linking majidkhan 1 April 29th, 10:00 AM
"SELECT rowguidcol" from tables on linked servers? brentbordelon 1 April 25th, 04:12 PM
"SELECT rowguidcol" vs. "SELECT <actual name>" rgarrison 9 April 16th, 03:46 PM







JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
Microsoft Article: Will Hyper-V Make VMware This Decade's Netscape?
Microsoft Article: 7.0, Microsoft's Lucky Version?
Microsoft Article: Hyper-V--The Killer Feature in Windows Server 2008
Avaya Article: How to Feed Data into the Avaya Event Processor
Microsoft Article: Install What You Need with Windows Server 2008
HP eBook: Putting the Green into IT
Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
Avaya Article: Setting Up a SIP A/S Development Environment
IBM Article: How Cool Is Your Data Center?
Microsoft Article: Managing Virtual Machines with Microsoft System Center
HP eBook: Storage Networking , Part 1
Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Intel Video: Are Multi-core Processors Here to Stay?
On-Demand Webcast: Five Virtualization Trends to Watch
HP Video: Page Cost Calculator
Intel Video: APIs for Parallel Programming
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Sun Download: Solaris 8 Migration Assistant
Sybase Download: SQL Anywhere Developer Edition
Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
Red Gate Download: SQL Compare Pro 6
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
IBM Article: Collaborating in the High-Performance Workplace
HP Demo: StorageWorks EVA4400
Intel Featured Algorhythm: Intel Threading Building Blocks--The Pipeline Class
Microsoft How-to Article: Get Going with Silverlight and Windows Live
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES