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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Problem with ShrikDatabase command

Author  Topic 

fcoreyesv
Starting Member

18 Posts

Posted - 2006-06-09 : 16:34:42
I am making a simple script to shrink a database. I am receiving the following message and I did not find the cause.

----------------------------------------------------------
Cannot shrink log file 2 (TestCompany_Log) because all logical log
files are in use.
DbId FileId CurrentSize MinimumSize UsedPages EstimatedPages
------ ------ ----------- ----------- ----------- --------------
7 2 85144 128 85144 128

(1 row affected)
DBCC execution completed. If DBCC printed error messages, contact your
system administrator.
------------------------------------------------------------

I am using the following command script:
---------------------------
DBCC ShrinkDatabase(testcompany,10)
GO
----------------------------------

and the following command to invoque osql:
-------------------------
OSQL -S servername -E -i Texfilename -o textfileName -n
-------------------------


Does anyone knows why is saying that those files are in use?

Thank you in advance for your help.

Francois

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-06-09 : 16:48:39
If you are using QA when executing the script, the QA holds a connection to the database. You can still use QA,but you can't have the database you're trying to shrink as the current database.

Choose Master database and qualify your database name with DBCC.
Go to Top of Page

fcoreyesv
Starting Member

18 Posts

Posted - 2006-06-09 : 16:53:43
I am sorry, you lost me with qualifying the database with DBCC

how can I do that?


I am running the script from command prompt "c:\> OSQL ...."
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-06-09 : 17:01:57
You are not running anything against the database, not even having QA open?
Go to Top of Page

fcoreyesv
Starting Member

18 Posts

Posted - 2006-06-09 : 17:06:25
No, and the funny thing is that the menu option in the Enterprise Manager works fine. I close the Enterprise manager with running the commmand line to invoque oSQL.

Go to Top of Page

rockmoose
SQL Natt Alfen

3279 Posts

Posted - 2006-06-09 : 17:30:15
You can still shrink the database while having connections open.
I only use the DBCC SHRINKFILE() command though, and only after having done major data removal, and I really want to reclaim the space.

You can give the dbcc shrinkfile a try.

rockmoose
Go to Top of Page
   

- Advertisement -