1.首先检查数据文件位置及名称
SELECT name,physical_name FROM sys.database_files
2.迁移
USE master;
GO
ALTER DATABASE tempdb
MODIFY FILE (NAME = tempdev, FILENAME = 'E:MSSQL empdb.mdf');
GO
ALTER DATABASE tempdb
MODIFY FILE (NAME = tempdev02, FILENAME = 'E:MSSQL empdb02.mdf');
GO
ALTER DATABASE tempdb
MODIFY FILE (NAME = tempdev03, FILENAME = 'E:MSSQL empdb03.mdf');
GO
ALTER DATABASE tempdb
MODIFY FILE (NAME = templog, FILENAME = 'E:MSSQL emplog.ldf');
GO
语句执行成功后会提示下次重启生效。
重启后执行 SELECT name,physical_name FROM sys.database_files 验证即可。