Skip to content

Commit

Permalink
Adding table check before we access table. Also remove duplicate even…
Browse files Browse the repository at this point in the history
…t which is now more extended #78
  • Loading branch information
PiJoCoder committed Aug 25, 2022
1 parent 9bae3c3 commit 88c7aa7
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 deletions sqlnexus/PerfStatsAnalysis.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2495,21 +2495,21 @@ end
end
go

create procedure proc_ExcessiveXevents
as
IF ((OBJECT_ID ('tbl_XEvents') IS NOT NULL) and (OBJECT_ID ('tbl_AnalysisSummary') IS NOT NULL))
begin
if exists (
select event_name from tbl_XEvents
where event_name in
('query_pre_execution_showplan', 'query_post_execution_showplan','query_post_compilation_showplan','lock_acquired','sql_statement_starting','sql_statement_completed','sp_statement_starting','sp_statement_completed')
)
begin
update tbl_analysissummary
set [status]=1
where name ='Detailed XEvent Tracing'
end
end
-- create procedure proc_ExcessiveXevents
-- as
-- IF ((OBJECT_ID ('tbl_XEvents') IS NOT NULL) and (OBJECT_ID ('tbl_AnalysisSummary') IS NOT NULL))
-- begin
-- if exists (
-- select event_name from tbl_XEvents
-- where event_name in
-- ('query_pre_execution_showplan', 'query_post_execution_showplan','query_post_compilation_showplan','lock_acquired','sql_statement_starting','sql_statement_completed','sp_statement_starting','sp_statement_completed')
-- )
-- begin
-- update tbl_analysissummary
-- set [status]=1
-- where name ='Detailed XEvent Tracing'
-- end
-- end

go

Expand Down Expand Up @@ -3377,8 +3377,10 @@ create procedure [usp_Expensive_TraceEvts_Used]
as
BEGIN


DECLARE @traceevent varchar (256), @events_string varchar(max) = '', @cntr int = 0
IF (OBJECT_ID ('tbl_profiler_trace_event_details') IS NOT NULL)
BEGIN

DECLARE @traceevent varchar (256), @events_string varchar(max) = '', @cntr int = 0

DECLARE expensive_traceevents CURSOR FOR
SELECT DISTINCT TOP 5 trace_event_name
Expand Down Expand Up @@ -3411,13 +3413,17 @@ BEGIN
WHERE Name = 'usp_Expensive_TraceEvts_Used'

END

END
END
go

CREATE PROCEDURE [usp_Expensive_XEvts_Used]
as
BEGIN

IF (OBJECT_ID ('tbl_XEvents') IS NOT NULL)
BEGIN

DECLARE @session_event varchar (256), @events_string varchar(max) = '', @cntr int = 0

Expand Down Expand Up @@ -3452,6 +3458,7 @@ BEGIN
WHERE Name = 'usp_Expensive_XEvts_Used'

END
END

END
go
Expand Down Expand Up @@ -3582,7 +3589,7 @@ exec proc_PowerPlan
go
exec proc_CheckTraceFlags
go
exec proc_ExcessiveXevents
--exec proc_ExcessiveXevents
go
exec proc_AutoStats
go
Expand Down

0 comments on commit 88c7aa7

Please sign in to comment.