Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


move db files to another directory


move db files to another directory

Author
Message
Leo.Miller
Leo.Miller
SSC-Addicted
SSC-Addicted (484 reputation)SSC-Addicted (484 reputation)SSC-Addicted (484 reputation)SSC-Addicted (484 reputation)SSC-Addicted (484 reputation)SSC-Addicted (484 reputation)SSC-Addicted (484 reputation)SSC-Addicted (484 reputation)

Group: General Forum Members
Points: 484 Visits: 1500
I strongly recommend you take the database OFFLINE rather than detaching. Detaching as mentioned removes the database from the system catalog, which means some database options (saved in the system catalog) are lost. These don't come back when you attache the database. An example of this id database chaining (which I recommend you don't used if at all possible).

Leo
Leo.Miller
Leo.Miller
SSC-Addicted
SSC-Addicted (484 reputation)SSC-Addicted (484 reputation)SSC-Addicted (484 reputation)SSC-Addicted (484 reputation)SSC-Addicted (484 reputation)SSC-Addicted (484 reputation)SSC-Addicted (484 reputation)SSC-Addicted (484 reputation)

Group: General Forum Members
Points: 484 Visits: 1500
Perry Whittle (12/5/2012)
Stopping sql server is a bit like using a sledge hammer to crack a nut. You only need to take the database offline as follows

ALTER DATABASE mydb SET OFFLINE



  • Once offline, copy the disk files to the new locations.

  • Bring the database online.

  • When the database comes online successfully delete the old files.



Yes I know :-) But I've known DBAs who want to do it that way.

Leo
Hemant.R
Hemant.R
SSC Rookie
SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)

Group: General Forum Members
Points: 48 Visits: 240
before moving file please take full backup of that database .

if you are using attached detached for this there may problem .

i had face problem while moving file to another location. it is giving file copying error,insufficient system resource ,
new file location is SAN drive and
mdf size is around 58 GB

or use attached detached,

please make database offline then move.
sqlfriends
sqlfriends
SSCrazy
SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)

Group: General Forum Members
Points: 2047 Visits: 3863
Perry Whittle (12/5/2012)
Stopping sql server is a bit like using a sledge hammer to crack a nut. You only need to take the database offline as follows

ALTER DATABASE mydb SET OFFLINE



  • Once offline, copy the disk files to the new locations.

  • Bring the database online.

  • When the database comes online successfully delete the old files.



It looks a step missing in above.

Before take offline, should there be a step that change the logical file to another directory?

I know how to do in SQL for this step, is there a way to do it in ssms?

Thanks
Perry Whittle
Perry Whittle
SSCrazy Eights
SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)

Group: General Forum Members
Points: 8786 Visits: 16558
sqlfriends (12/10/2012)
Perry Whittle (12/5/2012)
Stopping sql server is a bit like using a sledge hammer to crack a nut. You only need to take the database offline as follows

ALTER DATABASE mydb SET OFFLINE



  • Once offline, copy the disk files to the new locations.

  • Bring the database online.

  • When the database comes online successfully delete the old files.



It looks a step missing in above.

Before take offline, should there be a step that change the logical file to another directory?

I know how to do in SQL for this step, is there a way to do it in ssms?

Thanks

Yes, you need to use the ALTER DATABASE ... MODIFY FILE command but in your first post you've already done that!!!

-----------------------------------------------------------------------------------------------------------

"Ya can't make an omelette without breaking just a few eggs" ;-)
sqlfriends
sqlfriends
SSCrazy
SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)

Group: General Forum Members
Points: 2047 Visits: 3863
Thanks much!
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search