[SQL Server] method of transferring the location of the database MDF or LDF file, and restarting the issue with no permissions

Source: Internet
Author: User

0. View the database file name and physical file name

SELECT  as current_file_location  from Sys.master_files


1. Run the command

 UseMaster--Run from MasterALTER DATABASEdbmodifyFILE(Name='DB', filename='C:\NewPath\Database.mdf');ALTER DATABASEdbmodifyFILE(Name='db_LOG', filename='C:\NewPath\Database_log.ldf');ALTER DATABASEDbSETOFFLINE with ROLLBACKIMMEDIATE;


2. Move files, check permissions

* Move database files (including mdf/ldf) C:\NewPath

* Explorer: C:\NewPath, Properties----security--Add location: Select this machine, do not select domain-type ' NT service\mssqlserver ' search, select ' Mssqlserv ER ', allow Full Control

3. On-line

ALTER DATABASE SET ONLINE;

[SQL Server] method of transferring the location of the database MDF or LDF file, and restarting the issue with no permissions

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.