SQL SERVER DBA, Linux and Azure: TempDB-Move TempDB Script in SQL Server

TempDB-Move TempDB Script in SQL Server

Hi All,

Please find the below mentioned script to generate the Move tempdb script in SQL Server 

 --Move_tempdb.sql

/*

Author: Brent Ozar

Original link: https://www.brentozar.com/archive/2017/11/move-tempdb-another-drive-folder/

*/

USE MASTER

GO

SELECT 'ALTER DATABASE tempdb MODIFY FILE (NAME = [' + f.name + '],'

    + ' FILENAME = ''Z:\MSSQL\DATA\' + f.name

    + CASE WHEN f.type = 1 THEN '.ldf' ELSE '.mdf' END

    + ''');'

FROM sys.master_files f

WHERE f.database_id = DB_ID(N'tempdb');


No comments:

Post a Comment