Audit.EnumDatabaseAuditSpecification 메서드

Enumerates a list of databases and audit specifications defined by the audit.

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

구문

‘선언
Public Function EnumDatabaseAuditSpecification As DataTable
‘사용 방법
Dim instance As Audit 
Dim returnValue As DataTable 

returnValue = instance.EnumDatabaseAuditSpecification()
public DataTable EnumDatabaseAuditSpecification()
public:
DataTable^ EnumDatabaseAuditSpecification()
member EnumDatabaseAuditSpecification : unit -> DataTable
public function EnumDatabaseAuditSpecification() : DataTable

반환 값

유형: System.Data.DataTable
A DataTable system object value that contains a list of information about the databases in the audit. The following table describes the different columns of the returned DataTable.

Column

Data type

Description

Database Name

String

The name of the database.

DB Specification Name

String

The name of the database audit specification associated with the database.

The following code example demonstrates how to get the audit database and specification information.

C#

using System;
using System.Data;
using Microsoft.SqlServer.Management.Smo;

namespace samples
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create the audit
            Server dbServer = new Server("(local)");
            Audit dbAudit = new Audit(dbServer, "Test Audit");
            dbAudit.DestinationType = AuditDestinationType.File;
            dbAudit.FilePath = "C:\\AuditDirectory";
            dbAudit.Create();

            //Gets the audit database and specification information
            DataTable auditData = new DataTable("Test Audit Data");
            auditData = dbAudit.EnumDatabaseAuditSpecification();
        }
    }
}

Powershell

#Create the audit 
$dbServer = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")
$dbAudit = New-Object Microsoft.SqlServer.Management.Smo.Audit($dbServer, "Test Audit")
$dbAudit.DestinationType = [Microsoft.SqlServer.Management.Smo.AuditDestinationType]'File'
$dbAudit.FilePath = "C:\AuditDirectory"
$dbAudit.Create()

#Gets the audit database and specification information
$auditData = New-Object System.Data.DataTable("Test Audit Data") 
$auditData = $dbAudit.EnumDatabaseAuditSpecification()

참고 항목

참조

Audit 클래스

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