Compartir a través de


Audit.Drop Método

Removes the audit from the instance of SQL Server.

Espacio de nombres:  Microsoft.SqlServer.Management.Smo
Ensamblado:  Microsoft.SqlServer.Smo (en Microsoft.SqlServer.Smo.dll)

Sintaxis

'Declaración
Public Sub Drop
'Uso
Dim instance As Audit

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

Implementa

IDroppable.Drop()

Comentarios

The audit is removed with the FORCE_DROP option. The audit must be disabled by the Disable method before it can be dropped.

Ejemplos

The following code example demonstrates how to drop a disabled audit.

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

            //Drop the audit
            dbAudit.Drop();
        }
    }
}

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

#Drop the audit
$dbAudit.Drop()

Vea también

Referencia

Audit Clase

Espacio de nombres Microsoft.SqlServer.Management.Smo