Audit.Rename 메서드
Changes the name of the audit to the specified string.
네임스페이스: Microsoft.SqlServer.Management.Smo
어셈블리: Microsoft.SqlServer.Smo(Microsoft.SqlServer.Smo.dll)
구문
‘선언
Public Sub Rename ( _
newname As String _
)
‘사용 방법
Dim instance As Audit
Dim newname As String
instance.Rename(newname)
public void Rename(
string newname
)
public:
virtual void Rename(
String^ newname
) sealed
abstract Rename :
newname:string -> unit
override Rename :
newname:string -> unit
public final function Rename(
newname : String
)
매개 변수
- newname
유형: System.String
A string object specifying the new name of the audit.
구현
주의
The new audit name must be unique. Attempting to set the audit name to the same name as an existing audit will result in a FailedOperationException.
예
The following code example demonstrates how to rename an 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();
//Rename the audit and display the new name on the console
dbAudit.Rename("New Test Audit Name");
Console.WriteLine(dbAudit.Name);
}
}
}
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()
#Rename the audit and display the new name
$dbAudit.Rename("New Test Audit name")
Write-Host $dbAudit.Name