Solved

Trunicate Transaction Login in SQL 2008

Posted on 2014-02-09
6
240 Views
Last Modified: 2014-02-25
My SQL 2008 doesn't backup for a long time and the Log file partition is full.

After backing up the transaction log, the size is still remain the same. What else can I do to free up the space in the transaction log file ?

Tks
0
Comment
Question by:AXISHK
  • 3
  • 3
6 Comments
 
LVL 12

Expert Comment

by:Tony303
Comment Utility
I'd shrink the Database,
Then check the log file size.

To stop this happening again,
I'd do a full backup of the DB, then institute an hourly log backup.

Generally, a daily full backup and hourly log backups will suffice.

T
0
 

Author Comment

by:AXISHK
Comment Utility
The log will be automatically expanded. How to truncate it to a smaller size ?
0
 
LVL 12

Expert Comment

by:Tony303
Comment Utility
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:AXISHK
Comment Utility
Is there a sample script that I can reference to backup the database and Log onto a portable HDD.

- I need to backup the database and transaction log onto a portable device.
- truncate the transaction log
- shrink the log file

To test my understanding, backup transaction log with truncate will only remove the committed transaction but it can't resize the physical size of the log. I need to issue DBCC to shrink the transaction log (eg. resize it to 10Mb in the following case).

DBCC SHRINKFILE (<LogName>, 10240) WITH NO_INFOMSGS

What's the difference if I only issue DBCC SHRINKFILE((<LogName>) ?

Can we shrink the database ? If yes, under what situation ? Tks again.
0
 
LVL 12

Accepted Solution

by:
Tony303 earned 500 total points
Comment Utility
Hi,

I may run out of time on all these questions in 1 post...
But here goes...

I need to backup the database and transaction log onto a portable device.

I'd use the SQL Server Management Studio Maintenance Plans, create a new plan using the wizard and choose the Backup Database Task.
Once you have made the selections, there is a "View T-SQL" button.
This will show all the SQL needed to execute what you have created in the Wizard.

For each DB selected you'd see something like this....
BACKUP DATABASE [YourDB] TO  DISK = N'\\yourbakackupPath\YourDBName_backup_2014_02_11_161719_3854038.bak' WITH NOFORMAT, NOINIT,  NAME = N'YourDBName_backup_2014_02_11_161719_3854038', SKIP, REWIND, NOUNLOAD,  STATS = 10
GO

Open in new window


Ditto process for a .trn file backup, routine. Look at doing a new Maintenance Task wizard and go from there.

portable device

OK, Yes, I have the exact situation on a legacy machine and no internal disk space that I have to keep running for a few more months yet. So, the external drive is connected to the usb port on the machine that is hosting SQL. This drive has been made visible to the computer, I am not 100% sure how the engineers rigged it, but I am referencing it via a UNC path using an ip number.

So my path looks more like this

DISK = N'\\192.168.10.10\
Rather than this... I wrote above...
DISK = N'\\yourbakackupPath

Be aware backup up over USB is slow, real slow.

T
0
 

Author Closing Comment

by:AXISHK
Comment Utility
Tks
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Audit has been really one of the more interesting, most useful, yet difficult to maintain topics in the history of SQL Server. In earlier versions of SQL people had very few options for auditing in SQL Server. It typically meant using SQL Trace …
After restoring a Microsoft SQL Server database (.bak) from backup or attaching .mdf file, you may run into "Error '15023' User or role already exists in the current database" when you use the "User Mapping" SQL Management Studio functionality to al…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now