The following example moves tempdb from its current location on the disk to another disk location. Because tempdb is re-created each time the MSSQLSERVER service is started, you do not have to physically move the data and log files. The files are created when the service is restarted in step 3. Until the service is restarted, tempdb continues to function in its existing location.
-
Determine the logical file names of the tempdb database and their current location on disk.
2. Change the location of each file by using ALTER DATABASE.1: SELECT name, physical_name2: FROM sys.master_files3: WHERE database_id = DB_ID('tempdb');4: GO5:
1: USE master;2: GO3: ALTER DATABASE tempdb4: MODIFY FILE (NAME = tempdev, FILENAME = 'E:\SQLData\tempdb.mdf');5: GO6: ALTER DATABASE tempdb7: MODIFY FILE (NAME = templog, FILENAME = 'E:\SQLData\templog.ldf');8: GO9:
3. Stop and restart the instance of SQL Server.
4. Verify the file change.
1: SELECT name, physical_name2: FROM sys.master_files3: WHERE database_id = DB_ID('tempdb');
5. Delete the tempdb.mdf and templog.ldf files from their original location
Post a Comment
Post a Comment