SELECT 'ALTER DATABASE [tempdb] MODIFY FILE ' + CHAR(13) + ' (NAME = [' + [name] + '], FILENAME = ''D:\NewPath\' + [name] + CASE [type] WHEN 1 THEN '.ldf' ELSE '.mdf' END + ''');' FROM [sys].[master_files] WHERE [database_id] = DB_ID(N'tempdb')
SELECT 'ALTER DATABASE [tempdb] MODIFY FILE ' + CHAR(13) + ' (NAME = [' + [name] + '], FILENAME = ''D:\NewPath\' + [name] + CASE [type] WHEN 1 THEN '.ldf' ELSE '.mdf' END + ''');' FROM [sys].[master_files] WHERE [database_id] = DB_ID(N'tempdb')