Monday, February 20, 2012

Move data from NDF file to MDF file

Please could someone help?
I have a database which has two data files, mdf and ndf.
How can I move data from ndf into mdf and remove the ndf
file from the database?
Thanks in advance.
Alex
Hi,
To do this, use the DBCC SHRINKFILE with EMPTY FILE option for the NDF file
This will empty the file and mark it as unavailable. After this use ALTER
DATABASE.. REMOVE FILE option to remove the NDF file.
Steps:
1. Take a database backup
2.
Use database_name
go
DBCCSHRINKFILE('NDFFILE_name','EMPTYFILE')
3. Use ALTER database to Remove the file
ALTER DATABASE <DBNAME> REMOVE FILE 'logical ndf file name'
Thanks
Hari
MCDBA
Thanks
Hari
MCDBA
"Alex" <anonymous@.discussions.microsoft.com> wrote in message
news:19ee801c41d4f$c71cecc0$a401280a@.phx.gbl...
> Please could someone help?
> I have a database which has two data files, mdf and ndf.
> How can I move data from ndf into mdf and remove the ndf
> file from the database?
>
> Thanks in advance.
> Alex
|||Thank you very much Hari.
It worked!

>--Original Message--
>Hi,
>To do this, use the DBCC SHRINKFILE with EMPTY FILE
option for the NDF file
>This will empty the file and mark it as unavailable.
After this use ALTER
>DATABASE.. REMOVE FILE option to remove the NDF file.
>Steps:
>1. Take a database backup
>2.
>Use database_name
>go
>DBCCSHRINKFILE('NDFFILE_name','EMPTYFILE')
>3. Use ALTER database to Remove the file
> ALTER DATABASE <DBNAME> REMOVE FILE 'logical ndf file
name'
>Thanks
>Hari
>MCDBA
>Thanks
>Hari
>MCDBA
>
>"Alex" <anonymous@.discussions.microsoft.com> wrote in
message
>news:19ee801c41d4f$c71cecc0$a401280a@.phx.gbl...
>
>.
>

No comments:

Post a Comment