--========================================================================
MSlogreader_history 表存放本地分发服务器关联的日志读取器代理的历史记录
time
记录消息的时间。
delivery_latency
命令从进入发布数据库到进入分发数据库之间的滞后时间。
delivered_transactions
会话中传递的事务总数。
delivered_commands
会话中传递的命令总数。
average_commands
会话中传递的平均命令数。
--========================================================================
WITH T AS (
SELECT ROW_NUMBER()OVER(PARTITION BY agent_id ORDER BY time ASC) AS RID,
[agent_id],
[delivered_transactions],
[delivered_commands],
[average_commands],
[delivery_latency],
[time]
FROM distribution.dbo.MSlogreader_history
)
SELECT
T1.[agent_id],
T1.[time],
(T1.[delivered_transactions]-T2.[delivered_transactions]) AS Transcations,
(T1.[delivered_commands]-T2.[delivered_commands]) AS Commands,
T1.[delivery_latency]
FROM T AS T1
INNER JOIN T AS T2
ON T1.agent_id=T2.agent_id
AND T1.RID=T2.RID+1
参考:http://msdn.microsoft.com/zh-cn/library/ms176065(v=sql.120).aspx