SQLPROFILER計算機用戶操做數據SQL記錄跟蹤

/****** Script for F5計算機用戶操做數據SQL記錄跟蹤 ******/

SELECT HostName FROM SQL_KB_US_01 GROUP BY HostName
SELECT HostName FROM SQL_KB_US_02 GROUP BY HostName
SELECT HostName FROM SQL_KB_US_03 GROUP BY HostName

--SQL_KB_US_01
SELECT * FROM SQL_KB_US_01 WHERE HOSTNAME='KBC-AOI' 
--SQL_KB_US_02
SELECT * FROM SQL_KB_US_02 
--SQL_KB_US_03   
--TBINFOP 'SQL_KB_US_01'
--ROW_NUMBER() OVER(PARTITION BY COLUMN ORDER BY COLUMN)

SELECT * FROM SQL_KB_US_03 with (nolock) where HostName='QTA-ZZ-70'
SELECT * FROM SQL_KB_US_03 with (nolock) where HostName like '%QTA%'
SELECT distinct HostName FROM SQL_KB_US_03 with (nolock) where HostName like '%QTA%'
SELECT * FROM SQL_KB_US_03 with (nolock) where HostName like '%QTA%' order by HostName
SELECT HostName,count(HostName) 條數 FROM SQL_KB_US_03 with (nolock) where HostName like '%QTA%' group by HostName
SELECT * FROM SQL_KB_US_03 with (nolock) where HostName='QTA-ZZ-70'
SELECT HostName,TextData FROM SQL_KB_US_03 with (nolock) where HostName='QTA-ZZ-70'
SELECT ROW_NUMBER() OVER(PARTITION BY HostName ORDER BY HostName),HostName,TextData FROM SQL_KB_US_03 with (nolock) where HostName like '%QTA%' 
SELECT ROW_NUMBER() OVER(ORDER BY HostName),HostName,TextData FROM  SQL_KB_US_03 with (nolock) where HostName='QTA-ZZ-70'
--用戶SQL數目
SELECT HostName,count(HostName) 條數 FROM SQL_KB_US_03 with (nolock)  where HostName like '%%' group by HostName
SELECT HostName,count(HostName) 條數 FROM SQL_KB_US_03 with (nolock)  where HostName like '%%' group by HostName order by 條數 desc
SELECT HostName,count(HostName) 條數 FROM SQL_KB_US_03 with (nolock)  where HostName like '%AOI%' group by HostName
--先對HostName排序,再生成序號
SELECT ROW_NUMBER() OVER(PARTITION BY HostName ORDER BY HostName DESC) '排序',HostName '用戶計算機名',TextData '用戶操做數據記錄提取SQL語具' FROM SQL_KB_US_03 with (NOLOCK)
SELECT ROW_NUMBER() OVER(PARTITION BY HostName ORDER BY HostName DESC) '排序',HostName '用戶計算機名',TextData '用戶操做數據記錄提取SQL語具' FROM SQL_KB_US_03 with (NOLOCK) where HostName like '%%'
SELECT ROW_NUMBER() OVER(PARTITION BY HostName ORDER BY HostName DESC) '排序',HostName '用戶計算機名',TextData '用戶操做數據記錄提取SQL語具' FROM SQL_KB_US_03 with (NOLOCK) where HostName like '%AOI%'
--數據分析
--用戶操做SQL最多的條目分佈
SELECT HostName,count(HostName) 條數 FROM SQL_KB_US_03 where HostName like '%%' group by HostName order by 條數 desc    --條數 desc   
SELECT top 10 HostName,count(HostName) 條數 FROM SQL_KB_US_03 where HostName like '%%' group by HostName order by 條數 desc  --TOP 10 
SELECT  HostName '用戶計算機名',條數 FROM ( SELECT HostName,count(HostName) 條數  FROM SQL_KB_US_03 where HostName like '%%'  group by HostName) A WHERE 條數>500 order by 條數 desc    --條數>500
相關文章
相關標籤/搜索