Tuesday, March 27, 2012

Data File Offline

I have done a partial restore of a backup which leaves one of my data files
offline. I do not need this data file and would like to remove it from the
database. When I attempt to run ALTER DATABASE dbname REMOVE FILE filename I
recieve the following error:
"Cannot add, remove, or modify file 'filename' because it is offline."
Is there anyway to remove this file?
Thanks
You need to perform a couple of steps first.
1. Bring the datafile back online. I'm not sure what you mean by the file
is marked as offline.
2. Run DBCC SHRINKFILE with the EMPTYFILE option. This will remove data
from the file and keep SQL Server from placing data on the file.
3. Run the ALTER DATABASE command with the REMOVE FILE option.
HTH
Rick Sawtell
MCT, MCSD, MCDBA
"CraigA" <CraigA@.discussions.microsoft.com> wrote in message
news:AD111224-AD9F-463E-912C-1B168D223022@.microsoft.com...
> I have done a partial restore of a backup which leaves one of my data
files
> offline. I do not need this data file and would like to remove it from
the
> database. When I attempt to run ALTER DATABASE dbname REMOVE FILE
filename I
> recieve the following error:
> "Cannot add, remove, or modify file 'filename' because it is offline."
> Is there anyway to remove this file?
> Thanks

No comments:

Post a Comment