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

后端 未结 15 2638
挽巷
挽巷 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:10

    I stumbled across this solution in the documentation for the Create Database statement in the help for SQL Server:

    SELECT SUBSTRING(physical_name, 1, CHARINDEX(N'master.mdf', LOWER(physical_name)) - 1)
                      FROM master.sys.master_files
                      WHERE database_id = 1 AND file_id = 1
    

提交回复
热议问题