TruncateLog 方法
截斷資料庫記錄檔。
命名空間: Microsoft.SqlServer.Management.Smo
組件: Microsoft.SqlServer.Smo (在 Microsoft.SqlServer.Smo.dll 中)
語法
'宣告
Public Sub TruncateLog
'用途
Dim instance As Database
instance.TruncateLog()
public void TruncateLog()
public:
void TruncateLog()
member TruncateLog : unit -> unit
public function TruncateLog()
備註
Truncating the log means that records of completed transactions that make up the inactive part of the log are deleted. The remaining incomplete transactions in the active part of the log are not deleted. The log is usually truncated after a backup.
範例
VB
'Connect to the local, default instance of SQL Server.
Dim srv As Server
srv = New Server
'Reference the AdventureWorks2008R2 database.
Dim db As Database
db = srv.Databases("AdventureWorks2008R2")
'Shrink the database without truncating the log.
db.Shrink(20, ShrinkMethod.NoTruncate)
'Truncate the log.
db.TruncateLog()
PowerShell
$srv = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")
$db = New-Object Microsoft.SqlServer.Management.Smo.Database
$db = $srv.Databases.Item("AdventureWorks2008R2")
$db.Shrink(20, [Microsoft.SqlServer.Management.Smo.ShrinkMethod]'NoTruncate')
$db.TruncateLog()