June 17, 2005 at 9:56 am
Hello SQLers,
I am having a dumb problem with the DBCC SHRINKFILE command. I have attached a database called MyTemp from a different location C:\MyTemp\MyTemp_Data.mdf and this works file, but the moment I try to execute the command dbcc shrinkfile (MyTemp, -1), this is what io get:
Could not locate file 'MyTemp' in sysfiles.
Can someone help me here? I have tried reading the SQL Help, and it doesn't explain what is happening?
Thanks.
June 20, 2005 at 1:51 am
DBCC Shrinkfile expects the logical name of the file to be shrunk as the first parameter, not the name of the database.
Run sp_helpdb 'MyTemp' and see what it returns as the logical name of the file 'MyTemp_Data.mdf', then use that as the value for the first parameter of ShrinkFile
Or you can use DBCC ShrinkDatabase which does expect the database name as a parameter.
As an example, I've got a database named Treasure. It's data file has a logical name of 'Treasure_Data' and is located at 'D:\Data\Treasure.mdf'
HTH
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
June 20, 2005 at 7:21 am
Thank you very much.
This makes a lot of sense!
June 20, 2005 at 7:28 am
My pleasure.
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
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply