(A) Move USER database :3 methods
1 Backup and restore on new location
2. attach and detach database
3. Alter Command
First check current location
sp_helpdb 'database name'
or
SELECT name,physical_name FROM AdventureWorks.sys.database_files
ALTER DATABASE AdventureWorks SET OFFLINE
ALTER DATABASE AdventureWorks
MODIFY FILE (NAME = AdventureWorks_Data, FILENAME ='D:\MSSQL\Data\databasename.mdf');
ALTER DATABASE AdventureWorks
MODIFY FILE (NAME = AdventureWorks_Log, FILENAME ='D:\MSSQL\Log\databasename_Log.ldf');
ALTER DATABASE AdventureWorks SET ONLINE
1 Backup and restore on new location
2. attach and detach database
3. Alter Command
First check current location
sp_helpdb 'database name'
or
SELECT name,physical_name FROM AdventureWorks.sys.database_files
ALTER DATABASE AdventureWorks SET OFFLINE
ALTER DATABASE AdventureWorks
MODIFY FILE (NAME = AdventureWorks_Data, FILENAME ='D:\MSSQL\Data\databasename.mdf');
ALTER DATABASE AdventureWorks
MODIFY FILE (NAME = AdventureWorks_Log, FILENAME ='D:\MSSQL\Log\databasename_Log.ldf');
ALTER DATABASE AdventureWorks SET ONLINE
No comments:
Post a Comment