Thay đổi database name, logical_name, physical_name trong SQL Server
Thay đổi database name, logical_name, physical_name trong SQL Server
USE [nhaccuoi.com]
GO
SELECT file_id, name as [logical_file_name],physical_name
from sys.database_files
USE [master];
GO
ALTER DATABASE [nhaccuoi.com] MODIFY FILE ( NAME = [nhaccuoi.com_log], NEWNAME = [tiente.net_log] );
GO
USE [nhaccuoi.com];
GO
SELECT file_id, name AS logical_name, physical_name
FROM sys.database_files
USE [master];
GO
--Kill all DB connections
ALTER DATABASE [nhaccuoi.com] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
--take database in OFFLINE mode.
ALTER DATABASE [nhaccuoi.com] SET OFFLINE
ALTER DATABASE [nhaccuoi.com] SET ONLINE
Go
ALTER DATABASE [nhaccuoi.com] SET MULTI_USER
Go
ALTER DATABASE [nhaccuoi.com]
MODIFY FILE (Name='tiente.net', FILENAME='C:\Program Files (x86)\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQL\DATA\tiente.net.mdf')
GO
ALTER DATABASE [nhaccuoi.com]
MODIFY FILE (Name='tiente.net_log', FILENAME='C:\Program Files (x86)\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQL\DATA\tiente.net_log.ldf')
GO
ALTER DATABASE [nhaccuoi.com] MODIFY NAME = [tiente.net] ;