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 Programming
 Moving user database

Author  Topic 

sanjay kumar
Starting Member

7 Posts

Posted - 2011-05-04 : 05:41:24
Hello all,

I've a secondary file(.ndf) in D: drive, and for some reason that drive is full. and the .mdf and .ldf files are in other drive.

So, now i want to move the .ndf file from D: to other drive, like G: drive,

What is the procedure to move the secondary files from one drive to other.

Plz. help me

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-05-04 : 05:45:46
I would backup then restore with a move on that file after a test restore on another server to make sure the backup is ok.
Depends on how important the database is and how much downtime you can allow.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

sanjay kumar
Starting Member

7 Posts

Posted - 2011-05-04 : 05:54:24
Thanx for your kind support,

Like we move the system databases by executing the query ALTER DATABASE [DATABASENAME] MODIFY FILE (NAME='---', FILENAME='--'),

like this manner can't i move the secondary(.ndf) file to other drive?
Go to Top of Page

lionofdezert
Aged Yak Warrior

885 Posts

Posted - 2011-05-04 : 06:14:50
Detach your database --- move files to new locations -- attach your database by mentioning file path from new locations

--------------------------
http://connectsql.blogspot.com/
Go to Top of Page

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-05-04 : 06:31:15
I would do a backup before that - and given that you have a backup you might as well use it for the restore.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

sanjay kumar
Starting Member

7 Posts

Posted - 2011-05-04 : 06:40:09
Thank you all for your kind support...
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2011-05-04 : 07:56:49
Yes, you can use Alter DAtabase to move the user database files.

Run the alter database
Take the DB offline
Physically move the files
Bring the DB back online.

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

- Advertisement -