Metodo EnumDetachedDatabaseFiles
Enumera un elenco di file di database scollegati.
Spazio dei nomi Microsoft.SqlServer.Management.Smo
Assembly: Microsoft.SqlServer.Smo (in Microsoft.SqlServer.Smo.dll)
Sintassi
'Dichiarazione
Public Function EnumDetachedDatabaseFiles ( _
mdfName As String _
) As StringCollection
'Utilizzo
Dim instance As Server
Dim mdfName As String
Dim returnValue As StringCollection
returnValue = instance.EnumDetachedDatabaseFiles(mdfName)
public StringCollection EnumDetachedDatabaseFiles(
string mdfName
)
public:
StringCollection^ EnumDetachedDatabaseFiles(
String^ mdfName
)
member EnumDetachedDatabaseFiles :
mdfName:string -> StringCollection
public function EnumDetachedDatabaseFiles(
mdfName : String
) : StringCollection
Parametri
- mdfName
Tipo: System. . :: . .String
Valore String che specifica il nome file per il quale limitare i risultati.
Valore restituito
Tipo: System.Collections.Specialized. . :: . .StringCollection
Valore dell'oggetto di sistema StringCollection che contiene un elenco di nomi file relativi al database scollegato.
Osservazioni
Use this method to obtain the names of all detached database (.mdf and .ndf) files on the instance of SQL Server.
Esempi
C#
Server srv = new Server("(local)");
StringCollection sc = srv.EnumDetachedDatabaseFiles("C:\\Program Files\\Microsoft SQL Server\\MSSQL10_50.MSSQLSERVER\\MSSQL\\DATA\\DetachedDatabase.mdf");
foreach (String s in sc)
{
Console.WriteLine(s);
}
PowerShell
$srv = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")
$sc = $srv.EnumDetachedDatabaseFiles("C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\DetachedDatabase.mdf")
Foreach ($s in $sc)
{
Write-Host $s
}
Vedere anche