View or change the default locations for data and log files - SQL Server (2024)

Edit

Share via

  • Article

Applies to: View or change the default locations for data and log files - SQL Server (1) SQL Server - Windows only

The best practice for protecting your data files and log files is to ensure that they are protected by access control lists (ACLs). Set the ACLs on the directory root under which the files are created.

Note

These instructions are for SQL Server on Windows only. To change the default locations for SQL Server on Linux, see Configure SQL Server on Linux with the mssql-conf tool.

Use SQL Server Management Studio

  1. In Object Explorer, right-click on your server and select Properties.

  2. In the left panel on that Properties page, select the Database settings tab.

  3. In Database default locations, view the current default locations for new data files and new log files. To change a default location, enter a new default pathname in the Data or Log field, or select the browse button to find and select a pathname.

  4. After changing the default locations, you must stop and start the SQL Server service to complete the change.

Use Transact-SQL

Caution

The following example uses an extended stored procedure to modify the server registry. Serious problems might occur if you modify the registry incorrectly. These problems might require you to reinstall the operating system. Microsoft cannot guarantee that these problems can be resolved. Modify the registry at your own risk.

  1. Connect to the Database Engine.

  2. From the Standard bar, select New Query.

  3. Copy and paste the following example into the query window. Replace the <path_*> values with the new locations you wish to place your data and log files, and then select Execute.

    USE [master];GOEXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'BackupDirectory', REG_SZ, N'<path_to_database_backup_files>'GOEXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'DefaultData', REG_SZ, N'<path_to_data_files>'GOEXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'DefaultLog', REG_SZ, N'<path_to_log_files>'GO
  4. After changing the default locations, you must stop and start the SQL Server service to complete the change.

Related content

Feedback

Was this page helpful?

View or change the default locations for data and log files - SQL Server (2024)

FAQs

View or change the default locations for data and log files - SQL Server? ›

Use SQL Server Management Studio

How do I change the location of SQL Server data and log files? ›

Right-click the instance and select Properties. In the Server Properties dialog box, select Database Settings. Under Database Default Locations, browse to the new location for both the data and log files. Stop and start the SQL Server service to complete the change.

How do I change the default log file path in SQL Server? ›

  1. In SQL Server Management Studio right-click on the SQL Server name.
  2. Choose Prooperties.
  3. Choose Database Settings.
  4. Under "Database Default Locations" modify the Data and Log paths to the new, desired location.
Dec 19, 2014

What is the default location of SQL Server database files? ›

Common files used by all instances on a single computer are installed in the folder <drive>:\Program Files\Microsoft SQL Server\nnn\. <drive> is the drive letter where components are installed. The default is usually drive C.

How to change default database in SQL Server? ›

Set the default database for the user.
  1. Open SQL Server Management Studio.
  2. Open the database server in the Object Explorer (left panel).
  3. In Object Explorer, open Security > Logins.
  4. Right-click the user you created and choose Properties.
  5. On the General page, select a Default database. ...
  6. Click OK.

How do you view or change the default locations for data and log files? ›

In Object Explorer, right-click on your server and select Properties. In the left panel on that Properties page, select the Database settings tab. In Database default locations, view the current default locations for new data files and new log files.

Where is SQL log file location? ›

By default, the error log is located at Program Files\Microsoft SQL Server\MSSQL. n \MSSQL\LOG\ERRORLOG and ERRORLOG.

What is a data file and log file in SQL Server? ›

At a minimum, every SQL Server database has two operating system files: a data file and a log file. Data files contain data and objects such as tables, indexes, stored procedures, and views. Log files contain the information that is required to recover all transactions in the database.

Where is Access database default location? ›

By default, Access databases are stored at C:\OCS Documents\OST.

What is the default location for SQL backup? ›

The default backup directory is C:\Program Files\Microsoft SQL Server\MSSQL. n\MSSQL\Backup, where n is the number of the server instance. Therefore, for the default server instance, the default backup directory is: C:\Program Files\Microsoft SQL Server\MSSQL13. MSSQLSERVER\MSSQL\Backup.

How do I change the default database in login? ›

Open Sql Server Management Studio. Go to object Explorer -> Security -> Logins. Right click on the login and select properties. And in the properties window change the default database and click OK.

How do I change the default schema in SQL Server? ›

To change the schema of a table by using SQL Server Management Studio, in Object Explorer, right-click on the table and then click Design. Press F4 to open the Properties window. In the Schema box, select a new schema.

How do I change the default instance of SQL Server? ›

The instance configuration can't be changed after installation; the only way to change this is by uninstalling and reinstalling the instance. This is valid for all versions of SQL Server, including 2000 and 2005.

How do I move a SQL Server database log file? ›

In SQL Server, you can move system and user databases by specifying the new file location in the FILENAME clause of the ALTER DATABASE statement. Data, log, and full-text catalog files can be moved in this way.

How do I move a log file to a different drive? ›

Open the Event Viewer. Right-click the log name (for example, System) under Windows Logs in the left pane and select Properties. Change the Log path value to the location of the created folder and leave the log file name at the end of the path (for example, C:\EventLogs\System. evtx).

How do I change the backup location of a SQL Server database? ›

Right-click the SQL Server instance and select Properties. Select the Database Settings section. At the bottom of this window, you should see the Backup default location. Browse to the new Backup location and then close.

How do I restore a SQL Server database to a specific location? ›

In the Select a page pane, click the Options page. In the Restore database files as grid, specify a new location for the file or files that you want to move. The full path of a source backup file. Specifies the type of data in the backup: Data, Log, or Filestream Data.

Top Articles
MRI  Basics
15 Best Legit & Free Online Jobs That Pay Daily
Promotional Code For Spades Royale
Housing near Juneau, WI - craigslist
Mrh Forum
Professor Qwertyson
Noaa Weather Philadelphia
Goteach11
Mylife Cvs Login
Visustella Battle Core
What Happened To Father Anthony Mary Ewtn
Pollen Count Los Altos
4Chan Louisville
Culvers Tartar Sauce
Jack Daniels Pop Tarts
Betonnen afdekplaten (schoorsteenplaten) ter voorkoming van lekkage schoorsteen. - HeBlad
U/Apprenhensive_You8924
Ts Lillydoll
Letter F Logos - 178+ Best Letter F Logo Ideas. Free Letter F Logo Maker. | 99designs
Gdlauncher Downloading Game Files Loop
Epro Warrant Search
25Cc To Tbsp
Icommerce Agent
Unity - Manual: Scene view navigation
Ibukunore
Noaa Ilx
Loft Stores Near Me
O'Reilly Auto Parts - Mathis, TX - Nextdoor
Aes Salt Lake City Showdown
Rust Belt Revival Auctions
1 Filmy4Wap In
Bolsa Feels Bad For Sancho's Loss.
Package Store Open Near Me Open Now
Duke Energy Anderson Operations Center
Renfield Showtimes Near Marquee Cinemas - Wakefield 12
Vitals, jeden Tag besser | Vitals Nahrungsergänzungsmittel
Missouri State Highway Patrol Will Utilize Acadis to Improve Curriculum and Testing Management
The Mad Merchant Wow
Best Workers Compensation Lawyer Hill & Moin
Heavenly Delusion Gif
Lyca Shop Near Me
Bianca Belair: Age, Husband, Height & More To Know
Join MileSplit to get access to the latest news, films, and events!
Colorado Parks And Wildlife Reissue List
Electric Toothbrush Feature Crossword
COVID-19/Coronavirus Assistance Programs | FindHelp.org
Shipping Container Storage Containers 40'HCs - general for sale - by dealer - craigslist
Mychart Mercy Health Paducah
M&T Bank
Madden 23 Can't Hire Offensive Coordinator
Hy-Vee, Inc. hiring Market Grille Express Assistant Department Manager in New Hope, MN | LinkedIn
4015 Ballinger Rd Martinsville In 46151
Latest Posts
Article information

Author: Ray Christiansen

Last Updated:

Views: 5345

Rating: 4.9 / 5 (69 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Ray Christiansen

Birthday: 1998-05-04

Address: Apt. 814 34339 Sauer Islands, Hirtheville, GA 02446-8771

Phone: +337636892828

Job: Lead Hospitality Designer

Hobby: Urban exploration, Tai chi, Lockpicking, Fashion, Gunsmithing, Pottery, Geocaching

Introduction: My name is Ray Christiansen, I am a fair, good, cute, gentle, vast, glamorous, excited person who loves writing and wants to share my knowledge and understanding with you.