Поделиться через


Метод 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()