Created
September 5, 2018 03:55
-
-
Save LetsGoRafting/48f4d42901704dc35c7e02c5b6fb9cec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare @cnt varchar(300); | |
DECLARE @path NVARCHAR(260); | |
declare @cnt_n int; | |
--SELECT path FROM sys.traces WHERE is_default = 1 | |
--SELECT @path=path FROM sys.traces WHERE is_default = 1 | |
set @path='E:\SQLSYSTEM\MSSQL12.INST1\MSSQL\Log\log_244.trc' | |
select @path | |
--SELECT distinct DT.HostName | |
SELECT TE.name AS EventName, DT.DatabaseName, DT.ApplicationName, DT.HostName, | |
DT.LoginName, COUNT(*) AS Quantity | |
FROM dbo.fn_trace_gettable (@path, DEFAULT) DT | |
INNER JOIN sys.trace_events TE | |
ON DT.EventClass = TE.trace_event_id | |
GROUP BY TE.name , DT.DatabaseName , DT.ApplicationName, DT.LoginName, DT.HostName | |
order by LoginName | |
--------------------- | |
declare @cnt varchar(300); | |
DECLARE @path NVARCHAR(260); | |
declare @cnt_n int; | |
SELECT @path=path FROM sys.traces WHERE is_default = 1 | |
select @cnt_n = count(distinct DT.HostName) FROM dbo.fn_trace_gettable (@path, DEFAULT) DT | |
INNER JOIN sys.trace_events TE | |
ON DT.EventClass = TE.trace_event_id and DT.LoginName='SillyLogin' | |
and (DT.HostName like 'AKD%' or DT.HostName like 'AKL%') | |
if (@cnt_n) >0 | |
SELECT distinct DT.HostName | |
FROM dbo.fn_trace_gettable (@path, DEFAULT) DT | |
INNER JOIN sys.trace_events TE | |
ON DT.EventClass = TE.trace_event_id and DT.LoginName='Bally_PROD' | |
and (DT.HostName like 'AKD%' or DT.HostName like 'AKL%') | |
GROUP BY TE.name , DT.DatabaseName , DT.ApplicationName, DT.LoginName, DT.HostName |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment