다음을 통해 공유


Audit.Create 메서드

Creates an audit on the instance of SQL Server as defined by the Audit object.

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

구문

‘선언
Public Sub Create
‘사용 방법
Dim instance As Audit

instance.Create()
public void Create()
public:
virtual void Create() sealed
abstract Create : unit -> unit  
override Create : unit -> unit
public final function Create()

구현

ICreatable.Create()

주의

The DestinationType and FilePath audit properties must be defined before an audit can be created.

The following code example creates a new audit with the minimum required number of defined properties.

C#

using System;
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();
        }
    }
}

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()

참고 항목

참조

Audit 클래스

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