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 命名空间