Storage location for moving databases under SQL Server R2

Source: Internet
Author: User

Usage Scenario: 1. The database grows larger, the storage disk space is not enough;

2. In certain circumstances, the database needs to be moved to another disk (hehe ... My situation is that the previous disk will be returned to others)

Step: 1. New query

   

SELECT name, Physical_name
From Sys.master_files
WHERE database_id = db_id (' YourDatabaseName ');
GO

View the results to see the database Master file and the name of the log and the address name of the physical store

2. New Query

Use master
ALTER DATABASE AZPLATFORM01
Modify file (NAME = ' YourDatabaseName ', Filename = ' F:\DATA\yourDataBaseName.mdf ');
GO
ALTER DATABASE AZPLATFORM01
Modify file (NAME = ' Yourdatabasename_log ', Filename = ' F:\DATA\yourDataBaseName.ldf ');
GO

3. The database that will be moved offline

4. Manually copy the files to the destination path (F:\DATA\)

5. The database that will be moved is online

6. New Query

SELECT name, Physical_name
From Sys.master_files
WHERE database_id = db_id (' YourDatabaseName ');
GO

Verify through OK.

Experience is shallow, pat, welcome to Exchange

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.