How to move the database files from one logical driver to another Drive
-
domenica 11 marzo 2012 06:11
How to move the database files from one logical driver to another Drive?
What is the best practice ?. How to make sure everything is consistent successful
I have found the below things one article ? .Actually does all the thing below are required or just detach ,move and attach the database is not enough ?
----------------------------------
select name,physical_name from sys.master_files
alter database AdventureWorks
set offline
go
--make offline forcefully--You need to use WITH ROLLBACK IMMEDIATE to boot other conections out with no
regards to what or who is is already using it.
alter database AdventureWorks
set offline with rollback immediate
go
alter database AdventureWorks
modify file
(
name =AdventureWorks,
filename='P:\DATAFILES\AdventureWorks.mdf'
)
go
alter database AdventureWorks
modify file
(
name =AdventureWorks_log,
filename='R:\LOGFILES\AdventureWorks_log.Ldf'
)
go
--move the data file to the new directory we specified
alter database AdventureWorks
set online
go
select name,physical_name from sys.master_files
Tutte le risposte
-
domenica 11 marzo 2012 06:28Postatore
Yes it looks OK.... Someone prefer using attach\detach approach, I would prefer the script you posted aboveBest Regards, Uri Dimant SQL Server MVP http://dimantdatabasesolutions.blogspot.com/ http://sqlblog.com/blogs/uri_dimant/
- Proposto come risposta Warwick Rudd domenica 11 marzo 2012 20:06
- Contrassegnato come risposta KJian_ lunedì 19 marzo 2012 05:16
-
domenica 11 marzo 2012 06:55
Thanks
Can you give one reason why you prefer the script rather than detach \attach process .
What is the difference between the detach \attach process and the above script
-
domenica 11 marzo 2012 07:58Postatore
>>>Can you give one reason why you prefer the script rather than detach \attach process .
Its is just personal preference. Ideally, if you go for detach\attach option, have a last good backup in case something goes wrong.
>>What is the difference between the detach \attach process and the above script
1.Backup can be done online....
http://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/3e9c558b-3550-4d20-a12d-90cd2d2ed204/
Best Regards, Uri Dimant SQL Server MVP http://dimantdatabasesolutions.blogspot.com/ http://sqlblog.com/blogs/uri_dimant/
- Modificato Uri DimantMVP, Editor domenica 11 marzo 2012 07:59
-
domenica 11 marzo 2012 16:20
Detatch/attach is the "old" way. What you posted is the "new say".In general, you want to adapt the new method of doing things. For instance, detach/attach doesn't handle service broker (SB). OK, you might not be using SB today, but tomorrow there might be something else (new feature) that old method doesn't handle properly.- Proposto come risposta Warwick Rudd domenica 11 marzo 2012 20:06
- Contrassegnato come risposta KJian_ lunedì 19 marzo 2012 05:16
-
lunedì 12 marzo 2012 21:44Postatore
How to move the database files from one logical driver to another Drive?
You can restore the database from backup to different files:
http://www.sqlusa.com/bestpractices2005/restoredbwithsqlcmd/
Kalman Toth SQL SERVER & BI TRAINING
- Modificato Kalman TothMicrosoft Community Contributor, Editor lunedì 12 marzo 2012 21:45

