Procedure;
1. Check the logical name and location of tempdb. You can use the following statement:
Select name, physical_name
From SYS. master_files
Where database_id = db_id ('tempdb ');
2. Suspend the database service.
3. Copy the original tempdb file to the new location (the original file location can be obtained through the above query ).
3. Start the database service after the copy is completed.
4. Execute the following command:
Use master;
Go
Alter database tempdb
Modify file (name = tempdev, filename = 'e: \ tempdb. MDF ');
Go
Alter database tempdb
Modify file (name = templog, filename = 'e: \ tempdb \ templog. ldf ');
Go
Here, name = tempdev and templog are the logical names of tempdb, and filename = 'e: \ temdb \ tempdb. MDF 'is the new location of tempdb.
5. Check whether tempdb is successfully moved.
Select name, physical_name
From SYS. master_files
Where database_id = db_id ('tempdb ');