sp_cycle_errorlog (Transact-SQL)sp_cycle_errorlog (Transact-SQL)

適用於: 是SQL Server 否Azure SQL Database 否Azure Synapse Analytics (SQL DW) 否平行處理資料倉儲 APPLIES TO: yesSQL Server noAzure SQL Database noAzure Synapse Analytics (SQL DW) noParallel Data Warehouse

關閉目前的錯誤記錄檔,依照類似伺服器重新啟動的方式來循環處理錯誤記錄副檔名的號碼。Closes the current error log file and cycles the error log extension numbers just like a server restart. 新的錯誤記錄包含版本和著作權資訊,還會有一行指出已建立新記錄。The new error log contains version and copyright information and a line indicating that the new log has been created.

主題連結圖示 Transact-SQL 語法慣例Topic link icon Transact-SQL Syntax Conventions

語法Syntax

  
sp_cycle_errorlog  

傳回碼值Return Code Values

0 (成功) 或1 (失敗)0 (success) or 1 (failure)

結果集Result Sets

NoneNone

備註Remarks

每次SQL ServerSQL Server會啟動,目前的錯誤記錄檔已重新命名為errorlog.1;errorlog.1會變成errorlog.2errorlog.2會成為errorlog.3,依此類推。Every time SQL ServerSQL Server is started, the current error log is renamed to errorlog.1; errorlog.1 becomes errorlog.2, errorlog.2 becomes errorlog.3, and so on. sp_cycle_errorlog可讓您循環錯誤記錄檔,不需停止和啟動伺服器。sp_cycle_errorlog enables you to cycle the error log files without stopping and starting the server.

PermissionsPermissions

執行權限sp_cycle_errorlog的成員僅限於sysadmin固定的伺服器角色。Execute permissions for sp_cycle_errorlog are restricted to members of the sysadmin fixed server role.

範例Examples

下列範例會循環處理 SQL ServerSQL Server 錯誤記錄檔。The following example cycles the SQL ServerSQL Server error log.

EXEC sp_cycle_errorlog ;  
GO  

另請參閱See Also

系統預存程序 (Transact-SQL) System Stored Procedures (Transact-SQL)
sp_cycle_agent_errorlog (Transact-SQL)sp_cycle_agent_errorlog (Transact-SQL)