/ How to move tempdb files from one drive to other drive in SQL

How to move tempdb files from one drive to other drive in SQL

Issue : Space issue due to temp database growth on E drive . 

we had meeting with client and got confirmation from client to move temp data files from E to H drive .

Steps to Move Temp data files to E toH

1. First identify the location of the temp db file location 

select name,filename from sys.sysaltfiles where dbid=2

 tempdb files are located on  E:\MSSQL_default\Data\

now we need to move temp files to  H drive in following location

H:\MSSQL_default\Data\



2.    Please run the following query on Master db

USE master;
GO

ALTER DATABASE tempdb
MODIFY FILE (NAME = tempdev, FILENAME = 'H:\MSSQL_Default\Data\tempdb.mdf')

GO

ALTER DATABASE tempdb
MODIFY FILE (NAME = templog, FILENAME = 'H:\MSSQL_Default\Data\templog.ldf');
GO 

3. Restart the sql server services .
4 .verify the tempdb data files location using following query
select name,filename from sys.sysaltfiles where dbid=2