April 20, 2012 at 8:19 am
Hi,
I recently restored a database from an old SQL 2000 backup onto a SQL 2008 Standard Edition server. I set the recovery model to Simple and walked away.
I now find that there is 30Gb of data and a 60Gb of log file in that database. I would like to shrink or remove the log file to recover disk space, but SQL won't let me.
If I try and shrink the log, I get the error:
Could not locate file 'Mydb_log' for database 'Mydb' in sys.database_files. The file either does not exist or was dropped. (Microsoft SQL Server, Error: 8985).
The file is definitely there, and is 60Gb, so I really want to resize and/or get rid of it.
How can I do this?
Thanks,
Craig
April 20, 2012 at 8:28 am
Query sys.database_files and post the name, filename, id and type of all the files in there.
Do Not delete the log file. It can leave the database unusable.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
April 20, 2012 at 8:35 am
Results:
namephysical_namefile_guidfile_idtype
NewArchiveDataF:\Data\ArchiveData.mdfE4906318-99EC-4E9A-9BE2-EFEE790AACD710
NewArchiveData_logF:\Data\ArchiveData_log.ldfF0E37EDF-F3BB-468E-B00C-7DA012C5372C21
April 20, 2012 at 8:39 am
DBCC ShrinkFile ('NewArchiveData_log', 1000)
That'll try to shrink the log to 1GB.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
April 20, 2012 at 8:55 am
That basically gives the same error as I get in the UI :/
"Could not locate file 'NewArchiveData_log' for database 'ArchiveData' in sys.database_files. The file either does not exist, or was dropped. "
April 20, 2012 at 9:03 am
Are you running it in the correct database?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
April 20, 2012 at 9:05 am
Ha, yes. I just treble-checked and added a USE to be sure. I wish it was that simple 🙂
April 20, 2012 at 9:08 am
DBCC ShrinkFile (2, 1000)
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
April 20, 2012 at 9:09 am
Just to be sure, in Windows Explorer, does the file exist where sys.database_files says it does (F:\Data\ArchiveData_log.ldf)?
April 20, 2012 at 9:21 am
Yes, the file is there at that path.
April 20, 2012 at 9:22 am
GilaMonster (4/20/2012)
DBCC ShrinkFile (2, 1000)
It's now actually doing something using this command! 🙂
I'm not sure how long this will take though.
April 20, 2012 at 9:27 am
CraigIW (4/20/2012)
GilaMonster (4/20/2012)
DBCC ShrinkFile (2, 1000)It's now actually doing something using this command! 🙂
I'm not sure how long this will take though.
It took about three minutes 🙂
Thanks Gail, this worked. As the db is still on Simple recovery, I'm hoping I should be able to leave it now in this somewhat inconsistent state.
April 23, 2012 at 6:35 am
can you try changing it to full recovery, take transaction log backup and try shrinking the database, though this is not relates to your error
April 23, 2012 at 6:53 am
smardi5 (4/23/2012)
can you try changing it to full recovery, take transaction log backup
Why would you want to do that?
In simple recovery model the log space is marked reusable any time a checkpoint runs. In full recovery it requires a transaction log backup. So by switching to full recovery you increase the requirements to make the log reusable, not decrease them.
p.s. the transaction log backup will fail because there's been no full backup taken since the DB was switched to
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
April 23, 2012 at 7:00 am
I wanted him to check if he can take txn log backup, take it delete it, shirnk the db and revert back to simple model. as you rightly pointed out he will not be able to backup txn log since there is no full backup happened after restore.
Viewing 15 posts - 1 through 15 (of 16 total)
You must be logged in to reply to this topic. Login to reply