Thursday , December 26 2024

How To Move The Tempdb Database To Another Disk On SQL Server

 

I explained how to change the disks of a normal database in the article “How To Change The Disk Of Database Files On SQL Server“.

You cannot move tempdb with the same method.

Because the tempdb database is re-created by the sql server each time the SQL Server service starts.

Therefore, with the help of the following script, you can configure tempdb files to be created on the corresponding disks when the service is starrted again.

First of all, you should edit the script as I explained in the article.

 

In the above script, we configure 16 files of the tempdb database to be created on the disk named Disk01 mounted under the H drive.

You can find the concept of mount in my article “What is Mounted Drive and How to Create It“.

You will need to edit the above script according to your tempdb file number and the names of your files.

You can see the number and names of Tempdb files with the help of the following script.

Loading

About dbtut

We are a team with over 10 years of database management and BI experience. Our Expertises: Oracle, SQL Server, PostgreSQL, MySQL, MongoDB, Elasticsearch, Kibana, Grafana.

Leave a Reply

Your email address will not be published. Required fields are marked *