Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 Cannot shrink file '2' in database 'deptdata' to 1

Author  Topic 

stan_the_man21ph
Starting Member

5 Posts

Posted - 2011-01-28 : 00:25:24
Hi,

Is this error cause by performing this command:
DBCC SHRINKDATABASE(DatabaseName)?
Does the file '2' refer to the logfile?
How do I get rid of this error while still performing the dbcc shrinkdatabase command?

Is there a query wherein I could find the number of pages that the logfile contains so that I could perhaps trap this?

Thanks,
Stanley S.

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2011-01-28 : 04:49:36
Yes, file ID 2 is the log

Why are you shrinking the database?

Logs don't contain pages. You can use DBCC SQLPERF(LogSpace) to see how full the log is.

--
Gail Shaw
SQL Server MVP
Go to Top of Page

stan_the_man21ph
Starting Member

5 Posts

Posted - 2011-01-28 : 05:52:07
At first I thought the error "Cannot shrink file '2' in database 'deptdata' to 1" is cause by the dbcc shrinkdatabase command but I just tried to removed the command but I still got the errors. Any ideas what is causing this errors?

I'm using the shrinkdatabase command in an attempt to minimize the size of both the logs and data file. But right after im also performing reorganize afterwards.
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2011-01-28 : 08:02:44
It is caused by a shrink, database or file, or by autoshrink

Again, why are you shrinking the database? All you're doing is forcing it to grow again, that costs resources. Shrink should only be done if you've performed a large data archive or data purge. Otherwise leave the database alone, shrinking is going to hinder your performance, not help.

--
Gail Shaw
SQL Server MVP
Go to Top of Page
   

- Advertisement -