共用方式為


Audit.DateLastModified 屬性

Gets the date and time when the audit log was last modified.

命名空間:  Microsoft.SqlServer.Management.Smo
組件:  Microsoft.SqlServer.Smo (在 Microsoft.SqlServer.Smo.dll 中)

語法

'宣告
<SfcPropertyAttribute(SfcPropertyFlags.Standalone)> _
Public ReadOnly Property DateLastModified As DateTime 
    Get
'用途
Dim instance As Audit 
Dim value As DateTime 

value = instance.DateLastModified
[SfcPropertyAttribute(SfcPropertyFlags.Standalone)]
public DateTime DateLastModified { get; }
[SfcPropertyAttribute(SfcPropertyFlags::Standalone)]
public:
property DateTime DateLastModified {
    DateTime get ();
}
[<SfcPropertyAttribute(SfcPropertyFlags.Standalone)>]
member DateLastModified : DateTime
function get DateLastModified () : DateTime

屬性值

型別:System.DateTime
A DateTime system object value that specifies the time and date when the audit log was last modified.

範例

The following code example demonstrates how to get the date and time when the audit log was last modified, and displays that information on the console.

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

            //Display the date of the most recent modification to the 
            //log on the console
            DateTime auditModificationDate = dbAudit.DateLastModified;
            Console.WriteLine("The most recent modification of the  
                              audit log was made on " + 
                              auditModificationDate.ToString());
        }
    }
}

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

#Display the date of the most recent modification to the log
Write-Host "The most recent modification of the audit log was made on" 
            $dbAudit.DateLastModified

請參閱

參考

Audit 類別

Microsoft.SqlServer.Management.Smo 命名空間