网上也搜了一些资料,对有的语句还不是很放心,担心清理的时候,sql文件会被损坏,故先备份了
一遍。
------解决方案--------------------
回复记得引用
------解决方案--------------------
你的第五个库在做某个大容量操作,试试这个脚本:
SELECT DTST.[session_id] ,
DES.[login_name] AS [Login Name] ,
DB_NAME(DTDT.database_id) AS [Database] ,
DTDT.[database_transaction_begin_time] AS [Begin Time] ,
-- DATEDIFF(ms,DTDT.[database_transaction_begin_time], GETDATE()) AS [Durationms],
CASE DTAT.transaction_type
WHEN 1 THEN 'Read/write'
WHEN 2 THEN 'Read-only'
WHEN 3 THEN 'System'
WHEN 4 THEN 'Distributed'
END AS [Transaction Type] ,
CASE DTAT.transaction_state
WHEN 0 THEN 'Not fully initialized'
WHEN 1 THEN 'Initialized, not started'
WHEN 2 THEN 'Active'
WHEN 3 THEN 'Ended'
WHEN 4 THEN 'Commit initiated'
WHEN 5 THEN 'Prepared, awaiting resolution'
WHEN 6 THEN 'Committed'
WHEN 7 THEN 'Rolling back'
WHEN 8 THEN 'Rolled back'
END AS [Transaction State] ,
DTDT.[database_transaction_log_record_count] AS [Log Records] ,
DTDT.[database_transaction_log_bytes_used] AS [Log Bytes Used] ,
DTDT.[database_transaction_log_bytes_reserved] AS [Log Bytes RSVPd] ,
DEST.[text] AS [Last Transaction Text] ,
DEQP.[query_plan] AS [Last Query Plan]
FROM sys.dm_tran_database_transactions DTDT
INNER JOIN sys.dm_tran_session_transactions DTST ON DTST.[transaction_id] = DTDT.[transaction_id]
INNER JOIN sys.[dm_tran_active_transactions] DTAT ON DTST.[transaction_id] = DTAT.[transaction_id]
INNER JOIN sys.[dm_exec_sessions] DES ON DES.[session_id] = DTST.[session_id]
INNER JOIN sys.dm_exec_connections DEC ON DEC.[session_id] = DTST.[session_id]
LEFT JOIN sys.dm_exec_requests DER ON DER.[session_id] = DTST.[session_id]
CROSS APPLY sys.dm_exec_sql_text(DEC.[most_recent_sql_handle]) AS DEST
OUTER APPLY sys.dm_exec_query_plan(DER.[plan_handle]) AS DEQP
ORDER BY DTDT.[database_transaction_log_bytes_used] DESC;
-- ORDER BY [Duration ms] DESC;
------解决方案--------------------
日志文件这么大,是有点不太正常。
不过这个得看你的数据库的恢复模式,如果是simple,那么可以直接收缩。
如果是full,也可以修改为simple,然后直接收缩。
如果是full,已经做了完整备份和日志备份,那么可以备份日志,这样日志就能重复使用,然后再尝试收缩日志。
------解决方案--------------------
先说你的SQL SERVER版本 如果是2005 和2008的会一样的
可以通过日志压缩来进行清理的
2005和2008有所不同。
------解决方案--------------------
有活动事务,收缩不了
------解决方案--------------------
R2没问题....
------解决方案--------------------
算了,dbcc opentran执行这个
------解决方案--------------------
你针对第五个库吗?还是master?
------解决方案--------------------
继续:
SELECT DISTINCT TOP 3
t.TEXT QueryName,
s.execution_count AS ExecutionCount,
s.max_elapsed_time AS MaxElapsedTime,
--ISNULL(s.total_elapsed_time / s.execution_count, 0) AS AvgElapsedTime,
s.creation_time AS LogCreatedOn--,
--ISNULL(s.execution_count / DATEDIFF(s, s.creation_time, GETDATE()), 0) AS FrequencyPerSec
FROM sys.dm_exec_query_stats s