How do I find the data directory for a SQL Server instance?

后端 未结 15 2622
挽巷
挽巷 2020-11-30 23:16

We have a few huge databases (20GB+) which mostly contain static lookup data. Because our application executes joins against tables in these databases, they have t

15条回答
  •  清歌不尽
    2020-12-01 00:16

    You can find default Data and Log locations for the current SQL Server instance by using the following T-SQL:

    DECLARE @defaultDataLocation nvarchar(4000)
    DECLARE @defaultLogLocation nvarchar(4000)
    
    EXEC master.dbo.xp_instance_regread
        N'HKEY_LOCAL_MACHINE',
        N'Software\Microsoft\MSSQLServer\MSSQLServer',
        N'DefaultData', 
        @defaultDataLocation OUTPUT
    
    EXEC master.dbo.xp_instance_regread
        N'HKEY_LOCAL_MACHINE',
        N'Software\Microsoft\MSSQLServer\MSSQLServer',
        N'DefaultLog', 
        @defaultLogLocation OUTPUT
    
    SELECT @defaultDataLocation AS 'Default Data Location',
           @defaultLogLocation AS 'Default Log Location'
    

提交回复
热议问题