How to move tempdb to a new location in SQL Server

Source: Internet
Author: User

From: http://www.cnblogs.com/steven-zhou-2005/archive/2006/08/09/472042.html

Recently, when I was working on a database, I found that the disk space is often insufficient due to the large size of tempdb. To solve this problem, we use a solution to move tempdb to a new location. the procedure is as follows;
1. Check the logical name and location of tempdb. You can use the following statement:

Select Name, physical_name
From SYS. master_files
Where Database_id =   Db_id ( ' Tempdb ' );

2. Suspend the database service.
3. Copy the original tempdb file to the new location (the original file location can be obtained through the above query ).
3. Start the database service after the copy is completed.
4. Execute the following command: Use Master;
Go
Alter   Database Tempdb
Modify File (Name = Tempdev, filename =   ' E: \ tempdb. MDF ' );
Go
Alter   Database Tempdb
Modify File (Name = Templog, filename =   ' E: \ tempdb \ templog. LDF ' );
Go

Here, name = tempdev and templog are the logical names of tempdb, and filename = 'e: \ temdb \ tempdb. MDF 'is the new location of tempdb.
5. Check whether tempdb is successfully moved.

Select Name, physical_name
From SYS. master_files

WhereDatabase_id= Db_id('Tempdb'); 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.