January 5, 2013 at 10:42 am
I use SQL 2008. One of my database has its data file in drive D and log file in drive Z. Now, I need to move Data file from D to drive M.
I thought of using backup/restore with move and attach/detach. IMHO, backup/restore with MOVE is best option. Does someone confer with me on this or is there another best approach? After move, do i need to bounce sql service?
January 5, 2013 at 11:14 am
offline the database
use alter database...move file to change the metadata for the file location
physically COPY the file to the new location specified in the alter database command
bring the database online.
No sql restart required.
delete the old file once confirmed everything ok
---------------------------------------------------------------------
January 5, 2013 at 11:24 am
Contrary to popular belief you do not need to stop SQL Server, there, that's that over with 😉
To move the database files perform the following;
select name, physical_name from sys.master_fileswhere database_id = DB_ID('Corrupt2K8')
alter database yourdb modify file(name = logicalname,filename = 'drive: ewpath\filename.ext')
alter database mydb set offline with rollback immediate
-----------------------------------------------------------------------------------------------------------
"Ya can't make an omelette without breaking just a few eggs" 😉
January 5, 2013 at 11:58 am
Do you guys foresee any problem with
[Taking backup of db and restoring the same db and changing the file location while restoring]
Example:
Database: Inventory
Backup Inventory
Restore Inventory (replace existing Inventory DB), change data file location
Wont this method change the meta data?
January 5, 2013 at 1:02 pm
it will work and the metadata will be updated. The owner of the database will change which might not be what you want.
alter database is the accepted best method for moving a database file from sql2005 onwards
---------------------------------------------------------------------
January 5, 2013 at 1:45 pm
balasach82 (1/5/2013)
Do you guys foresee any problem with[Taking backup of db and restoring the same db and changing the file location while restoring]
Example:
Database: Inventory
Backup Inventory
Restore Inventory (replace existing Inventory DB), change data file location
Wont this method change the meta data?
Did you not read my post??
Yawn, I feel an article coming on 🙂
-----------------------------------------------------------------------------------------------------------
"Ya can't make an omelette without breaking just a few eggs" 😉
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply