Drop メソッド

SQL Server のインスタンスから監査を削除します。

名前空間:  Microsoft.SqlServer.Management.Smo
アセンブリ:  Microsoft.SqlServer.Smo (Microsoft.SqlServer.Smo.dll)

構文

'宣言
Public Sub Drop
'使用
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()

実装

IDroppable. . :: . .Drop() () () ()

説明

監査は、FORCE_DROP オプションを使用して削除されます。監査を削除する前に、Disable メソッドを使用して監査を無効にする必要があります。

使用例

次のコード例では、無効にした監査を削除する方法を示します。

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