1. Detach Database First
USE [master]
ALTER DATABASE [OLDAXBaseline]
SET SINGLE_USER WITH ROLLBACK IMMEDIATE
EXEC master.dbo.sp_detach_db @dbname = N'OLDAXBaseline'
USE [master]
ALTER DATABASE [OLDAX]
SET SINGLE_USER WITH ROLLBACK IMMEDIATE
EXEC master.dbo.sp_detach_db @dbname = N'OLDAX'
USE [master]
ALTER DATABASE [OLDAX_model]
SET SINGLE_USER WITH ROLLBACK IMMEDIATE
EXEC master.dbo.sp_detach_db @dbname = N'OLDAX_model'
2. Rename Database MDF and LDF files
manually
3. Create new database and Attached
Manually renamed Files
USE [master]
CREATE DATABASE AXBaseline ON
( FILENAME = N'C:\\DATA\AXBaseline.mdf'),
( FILENAME = N'C:\\DATA\AXBaseline_log.LDF')
FOR ATTACH
USE [master]
CREATE DATABASE AX ON
( FILENAME = N'C:\\DATA\AX.mdf'),
( FILENAME = N'C:\\DATA\AX_log.LDF')
FOR ATTACH
USE [master]
CREATE DATABASE AX_model ON
( FILENAME = N'C:\\DATA\AX_model.mdf'),
( FILENAME = N'C:\\DATA\AX_model_log.LDF')
FOR ATTACH
4. Change logical file name
USE [AXBaseline]
ALTER DATABASE [AXBaseline]
MODIFY FILE (NAME=N'OldAXBaseline', NEWNAME=N'AXBaseline')
ALTER DATABASE [AXBaseline]
MODIFY FILE (NAME=N'OldAXBaseline_log', NEWNAME=N'AXBaseline_log')
USE [AX]
ALTER DATABASE [AX]
MODIFY FILE (NAME=N'OldAX', NEWNAME=N'AX')
ALTER DATABASE [AX]
MODIFY FILE (NAME=N'OldAX_log', NEWNAME=N'AX_log')
USE [AX_model]
ALTER DATABASE [AX_model]
MODIFY FILE (NAME=N'OldAX_model', NEWNAME=N'AX_model')
ALTER DATABASE [AX_model]
MODIFY FILE (NAME=N'OldAX_model_log', NEWNAME=N'AX_model_log')