Link to home
Start Free TrialLog in
Avatar of Yuanyu
Yuanyu

asked on

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.
 
Avatar of nigelrivett
nigelrivett

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
Avatar of Yuanyu

ASKER

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?
Avatar of Yuanyu

ASKER

My database is 6.8G, and free disk space is 4M, can I run CHECKPOINT?
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.
Avatar of Yuanyu

ASKER

"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?
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
Avatar of Yuanyu

ASKER

"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?
Avatar of Yuanyu

ASKER

Delete the two log files?
Avatar of Yuanyu

ASKER

Is data safety?
Avatar of Yuanyu

ASKER

How to use 'sp_attach_single_file_db'?
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.
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.
"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.

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.
Avatar of Yuanyu

ASKER

--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?



Avatar of Yuanyu

ASKER

Which database should I select to run 'sp_spaceused syslogs' in SQl Analyzer?
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.
Avatar of Yuanyu

ASKER

nigelrivett,
   Could you answer the previous problem?
   And, after DBCC loginfo(dbname), What can I do?
   Can I remove the second log?
ASKER CERTIFIED SOLUTION
Avatar of nigelrivett
nigelrivett

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Yuanyu

ASKER

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.
Avatar of Yuanyu

ASKER

 It is OK in the case of one log file.
  How can I remove the second log?
Avatar of Yuanyu

ASKER

Use sp_attach_db can solve the problem.
Thank you very much!
Avatar of Yuanyu

ASKER

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.