Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
move_temp_db_files
-- Move TempDB Files.
USE tempdb
GO
-- Get logical file names.
EXEC sp_helpfile
-- Move data files.
ALTER DATABASE tempdb MODIFY FILE (
NAME = 'tempdev',
FILENAME = 'c:\sql_temp\tempdb.ndf')
ALTER DATABASE tempdb MODIFY FILE (
NAME = 'temp2',
FILENAME = 'c:\sql_temp\tempdb2.ndf')
ALTER DATABASE tempdb MODIFY FILE (
NAME = 'temp3',
FILENAME = 'c:\sql_temp\tempdb3.ndf')
ALTER DATABASE tempdb MODIFY FILE (
NAME = 'temp4',
FILENAME = 'c:\sql_temp\tempd4.ndf')
-- Move og files.
ALTER DATABASE tempdb MODIFY FILE (
NAME = 'templog',
FILENAME = 'c:\sql_temp\templog.ldf')
-- Restart SQL Service.
-- Verify change.
-- Delete old files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.