sql server 清空日志操作步骤
-- 恢复模式切换为简单模式
ALTER DATABASE [YourDatabaseName] SET RECOVERY SIMPLE;
GO
-- 备份日志
BACKUP LOG [YourDatabaseName] TO DISK = 'NUL:' ;
GO
-- 收缩日志文件,压缩日志为100M,此值可以修改
DBCC SHRINKFILE([YourDatabaseName]_log, 100);
GO
-- 清空日志文件内容
DBCC SHRINKFILE([YourDatabaseName], EMPTYFILE);
GO
-- 恢复模式切换回原模式
ALTER DATABASE [YourDatabaseName] SET RECOVERY FULL;
GO
--查询当前数据库的恢复模式
SELECT name,recovery_model,recovery_model_desc FROM sys.databases
WHERE name='[YourDatabaseName]'