다음을 통해 공유


Restore.ReadMediaHeader 메서드

Reads the media header and returns the media header values.

네임스페이스:  Microsoft.SqlServer.Management.Smo
어셈블리:  Microsoft.SqlServer.SmoExtended(Microsoft.SqlServer.SmoExtended.dll)

구문

‘선언
Public Function ReadMediaHeader ( _
    srv As Server _
) As DataTable
‘사용 방법
Dim instance As Restore 
Dim srv As Server 
Dim returnValue As DataTable 

returnValue = instance.ReadMediaHeader(srv)
public DataTable ReadMediaHeader(
    Server srv
)
public:
DataTable^ ReadMediaHeader(
    Server^ srv
)
member ReadMediaHeader : 
        srv:Server -> DataTable
public function ReadMediaHeader(
    srv : Server
) : DataTable

매개 변수

반환 값

유형: System.Data.DataTable
A DataTable object that specifies the media header data.

The following code example demonstrates how to back up file for the AdventureWorks2012 database and read the header values of the backup media.

VB

Dim srv As Server = New Server()
Dim res As Restore = New Restore()
Dim backup As Backup = New Backup()
Dim dt As DataTable

backup.Devices.AddDevice("C:\AdventureWorks2012Backup.bak", DeviceType.File)
backup.Database = "AdventureWorks2012"
backup.Action = BackupActionType.Database
backup.Initialize = True
backup.SqlBackup(srv)

res.Devices.AddDevice("C:\AdventureWorks2012Backup.BAK", DeviceType.File)
dt = res.ReadMediaHeader(srv)

For Each r As DataRow In dt.Rows
   For Each c As DataColumn In dt.Columns
      Console.WriteLine(c.ToString + " = " + r(c).ToString())
   Next
Next

PowerShell

$srv = new-object Microsoft.SqlServer.Management.Smo.Server("(local)")
$res = new-object Microsoft.SqlServer.Management.Smo.Restore
$backup = new-object Microsoft.SqlServer.Management.Smo.Backup

$backup.Devices.AddDevice("C:\AdventureWorks2012Backup.bak", [Microsoft.SqlServer.Management.Smo.DeviceType]::File)
$backup.Database = "AdventureWorks2012"
$backup.Action = [Microsoft.SqlServer.Management.Smo.BackupActionType]::Database
$backup.Initialize = $TRUE
$backup.SqlBackup($srv)

$res.Devices.AddDevice("C:\AdventureWorks2012Backup.bak", [Microsoft.SqlServer.Management.Smo.DeviceType]::File)
$dt = $res.ReadMediaHeader($srv)

foreach($r in $dt.Rows)
{
   foreach ($c in $dt.Columns)
   {
      Write-Host $c "=" $r[$c]
   }
}

참고 항목

참조

Restore 클래스

Microsoft.SqlServer.Management.Smo 네임스페이스

관련 자료

RESTORE(Transact-SQL)

SQL Server 데이터베이스 백업 및 복원