• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 688
  • Last Modified:

Disk is full

MS SQL 7.0 is installed in my NT4.0 server, the data disk is almost full, and where I delete some table's records, a error message is displayed: "The log file for database MyDatabaseName is full. Back up the transaction log for the database to free up some log space.". How can I free the log space?
Thanks.
 
0
Yuanyu
Asked:
Yuanyu
  • 14
  • 6
  • 2
  • +1
1 Solution
 
nigelrivettCommented:
try a backup command on the log with truuncate only.
Set the database option to truncate log on checkpoint (if you aren't relying on log backups which you probably aren't if you get this problem)

You should set a max size for the files to stop the disc filling up.

If you can't get anywhere try a sp_detach_db
copy the ldf to tape (if you don't have any room otherwise just rename it)
then sp_attach_single_file_db - this will create a 2MB ish log file
0
 
YuanyuAuthor Commented:
I have truncated transaction log, but "the log file is full" is still displayed, and I deleted some records, but disk space is not returned, when the space can be returned after records deleted?
0
 
YuanyuAuthor Commented:
My database is 6.8G, and free disk space is 4M, can I run CHECKPOINT?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
nigelrivettCommented:
Have you set the tran log to truncate on checkpoint?
this will happen automatically - or can just run checkpoint in a query window to force it.

Also set the tran log and database to increase in increments of 1 MB - it may need to write a log record to do anything.
If you can delete anything on this disc then do so.

also run

dbcc opentran('dbname')
where dbname is the database you are having problems with.
This will show any open transactions which may be stopping the log being cleared - it will only truncate up to the earliest uncommitted entry.
Try killing any spids that are holding transactions open.
0
 
YuanyuAuthor Commented:
"Truncate on checkpoint" is enable.
I used dbcc opentran('dbname'), and no active open transactions is found.
My database is related two transaction logs(I don't know why), when I run checkpoint, the first one can be truncate, but the second one cannot. Is the second one eating my disk space. How can I delete the second log?
0
 
nigelrivettCommented:
If you have no active transactions I would go for

Backup that database
sp_detach_db
delete the ldf files
then sp_attach_single_file_db
0
 
YuanyuAuthor Commented:
"Truncate on checkpoint" is enable.
I used dbcc opentran('dbname'), and no active open transactions is found.
My database is related two transaction logs(I don't know why), when I run checkpoint, the first one can be truncate, but the second one cannot. Is the second one eating my disk space. How can I delete the second log?
0
 
YuanyuAuthor Commented:
Delete the two log files?
0
 
YuanyuAuthor Commented:
Is data safety?
0
 
YuanyuAuthor Commented:
How to use 'sp_attach_single_file_db'?
0
 
nigelrivettCommented:
Backup the database

sp_detach_db 'dbname'
delete the log files (you can always restore the backup if it goes wrong)
sp_attach_single_file_db 'dbname', 'c:\...\filename.mdf'

It basically reattaches the mdf and creates a new tran log.
0
 
mgmanojCommented:
Better way is add one more log file the drive on which you have space & than try to truncate as per niquels suggestion it will work as to run the command also you need space in log file.
0
 
mathavraCommented:
"dump tran databasename with truncate_only" cannot be executed since it is a logged operation. Since the log is already full, you can't run that command.

You can run "dump transaction dbname with no_log" to clear the completely.

In some cases, even the no_log will not clear the log. It will comeback very quick and will do nothing. The only possibility for clearing this is by increasing it by couple of MB (say 5 MB) and run the dump tran dbname with truncate_only right away.

0
 
mathavraCommented:
There used to be a bug in SQLServer reporting the log space usage incorrectly. Do the following in that database and see what it shows:

1) Run the following command and find Used KB.

sp_spaceused syslogs

2) Run "select count(*) from syslogs" and see how many rows are in the syslogs table.

The UsedKB should show about 16KB at the most when syslog has less number of rows.

Can you post the results of the above commands.
0
 
YuanyuAuthor Commented:
--sp_attach_single_file_db 'dbname', 'c:\...\filename.mdf'
--It basically reattaches the mdf and creates a new tran log.

When I rename the log files name and run the "sp_attach_single_file_db", the new log cannot be created, and the database cannot be attached.

I don't need the second log file, how to delete it?



0
 
YuanyuAuthor Commented:
Which database should I select to run 'sp_spaceused syslogs' in SQl Analyzer?
0
 
nigelrivettCommented:
You need to be in the database whose log you want to check for sp_spaceused.

To look at log space used try
DBCC SQLPERF(logspace)
This will give a log report for all databases

better is
dbcc loginfo (dbname)
this will give an entry with status = 2 for the used pages.
0
 
YuanyuAuthor Commented:
nigelrivett,
   Could you answer the previous problem?
   And, after DBCC loginfo(dbname), What can I do?
   Can I remove the second log?
0
 
nigelrivettCommented:
dbcc loginfo will give info on used virtual files.
You can only shrink back to the last used virtual file - this is why the shrink doesn't always do anything.


Sorry I missed this post
When I rename the log files name and run the "sp_attach_single_file_db", the new log cannot be created,
and the database cannot be attached

What does it say in the error message? If it doesn't have space then you will have to delete some files frm the disc. Try deleting the log files rather than renaming them (keep a copy somewhere just in case though).
0
 
YuanyuAuthor Commented:
nigelrivett,
  Can I remove the second log?
 
  I do this in my test server, and its space is enough.My database is TT, interrelated logs are TT_Log and TT0_Log, when I do
  sp_attach_single_file_db 'TT','G:\MSSQL7\Data\tt_data.mdf'

  messages displayed as below:
Server: Msg 5105, Level 16, State 10, Line 1
Device activation error. The physical file name 'g:\MSSQL7\data\TT0_Log.LDF' may be incorrect.
Server: Msg 945, Level 14, State 1, Line 1
Database 'TT' cannot be opened because some of the files could not be activated.
Server: Msg 1813, Level 16, State 1, Line 1
Could not open new database 'TT'. CREATE DATABASE is aborted.

  After I rename the log files back, TT is returned.
0
 
YuanyuAuthor Commented:
 It is OK in the case of one log file.
  How can I remove the second log?
0
 
YuanyuAuthor Commented:
Use sp_attach_db can solve the problem.
Thank you very much!
0
 
YuanyuAuthor Commented:
nigelrivett,
  sorry, sp_attach_db cannot solve the problem actually.
  I ask a new question named 'How to remove the second log', welcome to point out the answer.
  thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 14
  • 6
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now