SELECT name, physical_name
FROM sys.master_files
WHERE database_id = DB_ID('TEMPDB');
GO

USE master;
GO
ALTER DATABASE TEMPDB
MODIFY FILE
(
    NAME = tempdev,
    FILENAME = N'D:\Database\tempdb.mdf'
);
GO

USE master;
GO
ALTER DATABASE TEMPDB
MODIFY FILE
(
    NAME = templog,
    FILENAME = N'D:\Database\templog.ldf'
);
GO

USE master
GO
ALTER DATABASE TEMPDB
SET OFFLINE WITH ROLLBACK IMMEDIATE
GO

USE master
GO
ALTER DATABASE TEMPDB
SET ONLINE
GO