Set SQL Server Database file location path

To workaround this, you need to just pass MDF and LDF file location as mentioned in the below script:


USE [master]
GO
--Data file
EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'DefaultData', REG_SZ, N'$(mdffilelocationpath)'
GO
-- Log file
EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'DefaultLog', REG_SZ, N'$(ldffilelocationpath)'
GO

Happy Coding....

No comments:

Post a Comment