SQL Server modifies database file storage location

Source: Internet
Author: User
Tags mssqlserver

1 --View current storage location2 SelectDatabase_id,name,physical_name ascurrentlocation,state_desc,size3  fromsys.master_files4 wheredatabase_id=db_id(N'Database name');5 6 --Change the location of the file to take effect the next time7 --TestDB is the database name,8 Alter DatabaseDatabase name Modifyfile(Name=FileName (does not contain a suffix), filename= 'File storage Path');9 Alter DatabaseDatabase name Modifyfile(Name=FileName (does not contain a suffix), filename= 'File storage Path');Ten eg. One Alter DatabaseTestDb Modifyfile(Name=TestDb, filename= 'G:\SQL_DATA\testDb\testDb.mdf'); A Alter DatabaseTestDb Modifyfile(Name=Testdb_log, filename= 'G:\SQL_DATA\testDb\testdb_log.ldf'); -  - --Modify the default database file storage location (immediate effect) the EXECXp_instance_regwrite - @rootkey='HKEY_LOCAL_MACHINE',  - @key='Software\microsoft\mssqlserver\mssqlserver',  - @value_name='Defaultdata',  + @type=REG_SZ, - @value='E:\MSSQL_MDF\data'  + GO  A --Modify the default log file location (immediate effect) at EXECMaster.. Xp_instance_regwrite - @rootkey='HKEY_LOCAL_MACHINE',  - @key='Software\microsoft\mssqlserver\mssqlserver',  - @value_name='Defaultlog',  - @type=REG_SZ, - @value='E:\MSSQL_MDF\log'  in GO

SQL Server modifies database file storage location

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.