SQL Server modifies database file and log file storage location _mssql

Source: Internet
Author: User
Tags mssqlserver
--View Current storage location Select Database_id,name,physical_name as Currentlocation,state_desc,size from Sys.master_files where Datab 
 
ase_id=db_id (N ' database name '); 
--Modify the location of the file to start the next time the--TESTDB is the database name, ALTER DATABASE name modify file (name = filename (not including suffix), filename = ' file storage path '); 
ALTER DATABASE name modify file (name = filename (not including suffix), filename = ' file storage path '); 
  eg. 
  ALTER DATABASE TestDB modify file (name = testdb, filename = ' G:\SQL_DATA\testDb\testDb.mdf '); 
 
ALTER DATABASE TestDB modify file (name = testdb_log, filename = ' G:\SQL_DATA\testDb\testdb_log.ldf '); --Modify the default database file location (immediate effect) EXEC xp_instance_regwrite @rootkey = ' hkey_local_machine ', @key = ' software\microsoft\ Mssqlserver\mssqlserver ', @value_name = ' Defaultdata ', @type =reg_sz, @value = ' E:\MSSQL_MDF\data ' Go--Modify default log file storage location <span style= "font-family:arial, Helvetica, Sans-serif;" > (immediate effect) </span> EXEC master. Xp_instance_regwrite @rootkey = ' hkey_local_machine ', @key = ' software\microsoft\mssqlserver\mssqlserver ', @value_ Name= ' DEfaultlog ', @type =reg_sz, @value = ' E:\MSSQL_MDF\log ' Go 
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.