Skip to content

Commit

Permalink
set default location sql database
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgfierro committed Mar 26, 2017
1 parent f00bcfc commit 7d9ee15
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions sql/sql_server/set_database_file_location.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
--
-- Script to change the default locations to save the database files
--

USE [master]
GO

-- Change default location for data files
EXEC   xp_instance_regwrite
       N'HKEY_LOCAL_MACHINE',
       N'Software\Microsoft\MSSQLServer\MSSQLServer',
       N'DefaultData',
       REG_SZ,
       N'E:\mssql_databases'
GO

-- Change default location for log files
EXEC   xp_instance_regwrite
       N'HKEY_LOCAL_MACHINE',
       N'Software\Microsoft\MSSQLServer\MSSQLServer',
       N'DefaultLog',
       REG_SZ,
       N'E:\mssql_databases\logs'
GO

-- Change default location for backups
EXEC   xp_instance_regwrite
       N'HKEY_LOCAL_MACHINE',
       N'Software\Microsoft\MSSQLServer\MSSQLServer',
       N'BackupDirectory',
       REG_SZ,
       N'E:\mssql_databases\backup'
GO

0 comments on commit 7d9ee15

Please sign in to comment.