I had the same problem. Every time I tried to backup the
transaction log (included in my Maintenance Plan), I got an
error that the log could not be backed up, unless the DB was
in single-user mode.
I read through several books, BOS, even posted several
messages on this newsgroup, just like you. But, could not
get my answer. I finally got the answer.
First, ignore the "single user mode" error. I don't know
why SQL Server provides this error message.
The reason why you can't backup the log (and several of the
system databases), is because you have your database in
SIMPLE RECOVERY MODE. You need to change this to FULL
recovery mode.
Can you believe this? After taking a course in SQL Server
2000 Administration, reading 2 full training books, and
working with SQL Server 2K for over 2 years, that NOWHERE
did I find out that the reason the transaction log wouldn't
backup, is because the DB recovery method was set to SIMPLE?
I can't believe something this important isn't covered or
mentioned in documentation. Nor, was anyone on this
newsgroup able to help. That's why I'm taking the time to
help you, because I wish someone would have given me this
information several years ago.
As a result, only recently was I able to backup my
transaction log, for the first time in almost 2 years. It
was 13 Gigs in size. (Now, it's about 20 megs).
To do this, open Enterprise Mgr, and right-click on your
database, and choose PROPERTIES. Under the OPTIONS tab,
change recovery mode to FULL. After doing this, you might
want to take your database OFFLINE, then ONLINE. To do
this, just right-click your database, and choose TAKE
OFFLINE. Then, wait 10-15 seconds, then choose BRING ONLINE.
You can now backup your log, and any of the system databases
that wouldn't backup.
Keep in mind that when you have your database in SIMPLE
recovery mode, you can only RESTORE the database from the
last FULL BACKUP performed on your database.
If recovery mode is set to FULL, you can RESTORE your
database at any point, from the last full backup to current
day/time. However, in FULL mode, the transaction log will
grow. This is because the log is used to help restore your
database, so it keeps track of all the transactions since
the last backup.
Also, in FULL mode, you'll need to regularly backup your
database AND transaction log. And remember to SHRINK the DB
and LOG after the backup, in order to keep the transaction
log to a reasonable size. Otherwise, if you don't shrink
it, it will grow and grow (if your settings allow unlimited
growth), until all your disk space is used up.
Many people backup the log every n hours, or once/day, and
run the backups daily or weekly.
Sometimes when you use the SHRINK database command (using
FILES, to select the LOG file), it doesn't actually shrink
the LOG. So, you may have to use the DBCC SHRINKDATABASE or
SHRINKFILE transact SQL. I still haven't figured this one
out, as far as the syntax.
So, I use a technique, taught to me by a nice person on this
newsgroup, that WILL shrink the log file (in actual size),
using EM's SHRINK DATABASE (FILES) option. If you would
like this info, let me know, and I'll post it. Good luck.
jj
=============== ============
Mark S wrote:
I have a db maintenance plan which is set to backup (then truncate
hopefully) the transaction log. In order to backup a transaction log the
db must be in single user mode so the maint. plan fails. How do you
automatically set the db, in single user mode, for the transaction log
to be backed up then truncated?
Also, I manually set the db in single user mode and it shows itself to
be in single user mode yet the number of users in the db properties says
there are 8 users connected. What's this about?
Thanks
Mark