What are the different ways to move User Databases in SQLServer?
There are different methods to move user databases from one location to another location
- Attach/Dettach Method
- Take Full backup and Restore
- Alter Database command within same instance
- Transfer Database Task through SSIS
Out of 4 methods first and fourth methods you can follow to move a user database within same instance or on other instance, whereas 2nd is for moving to other instance and 3rd method is only applicable within same instance
Attach/Dettach:
This is the simple and easy method
- Connect to SQLInstance through SSMS
- Click on database which you want to move
- Right click and select Dettach
- Move database files (.MDF an d.LDF) locations to new location
- Right click on Databases select Attach
- Here give new .MDF and .LDF location
Take Full backup and Restore:
- Connect to SQLInstance through SSMS
- Click on database which you want to move
- Right click –Tasksà Backup
- Take full backup
- Copy the backup to other sql server
- Restore it
Alter Database command:
- Run following command
USE master;
GO
ALTER DATABASE ABC
MODIFY FILE (NAME = ABC, FILENAME = 'E:\SQLData\ ABCdata.mdf');
GO
ALTER DATABASE ABC
MODIFY FILE (NAME = ABC, FILENAME = 'F:\SQLLog\ ABC log.ldf');
GO
2. Copy the files to new location
3. Restart SQL Services.
Transfer Database Task through SSIS:
The Transfer Database Task is used to move a database to another SQL Server instance or create a copy on the same instance (with different database name).
No comments:
Post a Comment