USE AssetMgmtServices_May2012
-- Replace all MyDBs with the name of the DB you want to change its name
USE AssetMgmtServices_May2012;
-- Changing Physical names and paths
-- Replace all NewMyDB with the new name you want to set for the DB
-- Replace 'C:\...\NewMyDB.mdf' with full path of new DB file to be used
ALTER DATABASE AssetMgmtServices_May2012 MODIFY FILE (NAME = 'AssetMgmtServices', FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER2012\MSSQL\DATA\AssetMgmtServices_May2012.mdf');
-- Replace 'C:\...\NewMyDB_log.ldf' with full path of new DB log file to be used
ALTER DATABASE AssetMgmtServices_May2012 MODIFY FILE (NAME = 'AssetMgmtServices_log', FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER2012\MSSQL\DATA\AssetMgmtServices_May2012_log.ldf');
-- Changing logical names
ALTER DATABASE AssetMgmtServices_May2012 MODIFY FILE (NAME = 'AssetMgmtServices', NEWNAME = 'AssetMgmtServices_May2012');
ALTER DATABASE AssetMgmtServices_May2012 MODIFY FILE (NAME = 'AssetMgmtServices_log', NEWNAME = 'AssetMgmtServices_May2012_log');
ALTER DATABASE AssetMgmtServices_May2012 SET OFFLINE WITH
ROLLBACK IMMEDIATE
--Physically change the file name
ALTER DATABASE AssetMgmtServices_May2012 SET ONLINE