SQL Clone
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
Ten Centuries
Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)

Group: General Forum Members
Points: 1370 Visits: 1537
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
Ten Centuries
Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)

Group: General Forum Members
Points: 1370 Visits: 1537
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-Enthusiastic
SSC-Enthusiastic (164 reputation)SSC-Enthusiastic (164 reputation)SSC-Enthusiastic (164 reputation)SSC-Enthusiastic (164 reputation)SSC-Enthusiastic (164 reputation)SSC-Enthusiastic (164 reputation)SSC-Enthusiastic (164 reputation)SSC-Enthusiastic (164 reputation)

Group: General Forum Members
Points: 164 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
SSCertifiable
SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)

Group: General Forum Members
Points: 5085 Visits: 4087
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
One Orange Chip
One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)

Group: General Forum Members
Points: 26705 Visits: 17338
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
SSCertifiable
SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)

Group: General Forum Members
Points: 5085 Visits: 4087
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