Partager via


Méthode Audit.Create

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

Espace de noms :  Microsoft.SqlServer.Management.Smo
Assembly :  Microsoft.SqlServer.Smo (en Microsoft.SqlServer.Smo.dll)

Syntaxe

'Déclaration
Public Sub Create
'Utilisation
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()

Implémente

ICreatable.Create()

Notes

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

Exemples

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

Voir aussi

Référence

Audit Classe

Espace de noms Microsoft.SqlServer.Management.Smo