Created
January 9, 2025 12:32
-
-
Save petesql/84344e47016ae84fc094c85381366f32 to your computer and use it in GitHub Desktop.
Generate SQL: Move TempDB Database Files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Prepare SQL for TempDB Database File Move | |
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'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment