How can I find out the location of my (localdb) SQL Server 2012 database and back it up?

前端 未结 7 1161
旧巷少年郎
旧巷少年郎 2021-02-01 15:09

I am using VS2012 and I have a database created:

(localdb)\\v11.0 (SQL Server 11.0.2100 - T61\\Alan)

How can I find out the physical location o

7条回答
  •  盖世英雄少女心
    2021-02-01 15:45

    This PowerShell script, will give you the default location for localdb .mdf files:

    [System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO') | out-null
    (New-Object Microsoft.SqlServer.Management.Smo.Server("(localdb)\$instancename")).DefaultFile
    

    where $instancename is the name of the localdb instance you want to check for. You can get a list of localdb instances by running

    sqllocaldb i
    

提交回复
热议问题