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

后端 未结 15 2577
挽巷
挽巷 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-11-30 23:52

    Even though this is a very old thread, I feel like I need to contribute a simple solution. Any time that you know where in Management Studio a parameter is located that you want to access for any sort of automated script, the easiest way is to run a quick profiler trace on a standalone test system and capture what Management Studio is doing on the backend.

    In this instance, assuming you are interested in finding the default data and log locations you can do the following:

    SELECT
         SERVERPROPERTY('instancedefaultdatapath') AS [DefaultFile],
         SERVERPROPERTY('instancedefaultlogpath') AS [DefaultLog]

提交回复
热议问题