Skip to content

Commit 8ac7d76

Browse files
Merge pull request #557 from erikdarlingdata/dev
Dev
2 parents effb9bd + 31c6dfb commit 8ac7d76

File tree

3 files changed

+249
-70
lines changed

3 files changed

+249
-70
lines changed

sp_HumanEvents/sp_HumanEvents.sql

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,39 +1227,6 @@ BEGIN
12271227
);
12281228
END;
12291229

1230-
/*
1231-
If we're writing to a table, we don't want to do anything else
1232-
Or anything else after this, really
1233-
We want the session to get set up
1234-
*/
1235-
IF @debug = 1 BEGIN RAISERROR(N'Do we skip to the GOTO and log tables?', 0, 1) WITH NOWAIT; END;
1236-
IF
1237-
(
1238-
@output_database_name <> N''
1239-
AND @output_schema_name <> N''
1240-
AND @cleanup = 0
1241-
)
1242-
BEGIN
1243-
IF @debug = 1 BEGIN RAISERROR(N'Skipping all the other stuff and going to data logging', 0, 1) WITH NOWAIT; END;
1244-
GOTO output_results;
1245-
RETURN;
1246-
END;
1247-
1248-
1249-
/* just finishing up the second coat now */
1250-
IF @debug = 1 BEGIN RAISERROR(N'Do we skip to the GOTO and cleanup?', 0, 1) WITH NOWAIT; END;
1251-
IF
1252-
(
1253-
@output_database_name <> N''
1254-
AND @output_schema_name <> N''
1255-
AND @cleanup = 1
1256-
)
1257-
BEGIN
1258-
IF @debug = 1 BEGIN RAISERROR(N'Skipping all the other stuff and going to cleanup', 0, 1) WITH NOWAIT; END;
1259-
GOTO cleanup;
1260-
RETURN;
1261-
END;
1262-
12631230

12641231
/* Start setting up individual filters */
12651232
IF @debug = 1 BEGIN RAISERROR(N'Setting up individual filters', 0, 1) WITH NOWAIT; END;
@@ -1705,8 +1672,10 @@ EXECUTE (@session_sql);
17051672
IF @debug = 1 BEGIN RAISERROR(@start_sql, 0, 1) WITH NOWAIT; END;
17061673
EXECUTE (@start_sql);
17071674

1708-
/* bail out here if we want to keep the session */
1709-
IF @keep_alive = 1
1675+
/* bail out here if we want to keep the session and not log to tables*/
1676+
IF @keep_alive = 1
1677+
AND @output_database_name = N''
1678+
AND @output_schema_name IN (N'', N'dbo')
17101679
BEGIN
17111680
IF @debug = 1
17121681
BEGIN
@@ -1718,6 +1687,38 @@ BEGIN
17181687
RETURN;
17191688
END;
17201689

1690+
/*
1691+
If we're writing to a table, we don't want to do anything else
1692+
Or anything else after this, really
1693+
We want the session to get set up
1694+
*/
1695+
IF @debug = 1 BEGIN RAISERROR(N'Do we skip to the GOTO and log tables?', 0, 1) WITH NOWAIT; END;
1696+
IF
1697+
(
1698+
@output_database_name <> N''
1699+
AND @output_schema_name <> N''
1700+
AND @cleanup = 0
1701+
)
1702+
BEGIN
1703+
IF @debug = 1 BEGIN RAISERROR(N'Skipping all the other stuff and going to data logging', 0, 1) WITH NOWAIT; END;
1704+
GOTO output_results;
1705+
RETURN;
1706+
END;
1707+
1708+
1709+
/* just finishing up the second coat now */
1710+
IF @debug = 1 BEGIN RAISERROR(N'Do we skip to the GOTO and cleanup?', 0, 1) WITH NOWAIT; END;
1711+
IF
1712+
(
1713+
@output_database_name <> N''
1714+
AND @output_schema_name <> N''
1715+
AND @cleanup = 1
1716+
)
1717+
BEGIN
1718+
IF @debug = 1 BEGIN RAISERROR(N'Skipping all the other stuff and going to cleanup', 0, 1) WITH NOWAIT; END;
1719+
GOTO cleanup;
1720+
RETURN;
1721+
END;
17211722

17221723
/* NOW WE WAIT, MR. BOND */
17231724
WAITFOR DELAY @waitfor;

sp_IndexCleanup/sp_IndexCleanup.sql

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
SET ANSI_WARNINGS ON;
1+
SET ANSI_WARNINGS ON;
22
SET ARITHABORT ON;
33
SET CONCAT_NULL_YIELDS_NULL ON;
44
SET QUOTED_IDENTIFIER ON;
@@ -7,6 +7,40 @@ SET IMPLICIT_TRANSACTIONS OFF;
77
SET STATISTICS TIME, IO OFF;
88
GO
99

10+
11+
/*
12+
██╗███╗ ██╗██████╗ ███████╗██╗ ██╗
13+
██║████╗ ██║██╔══██╗██╔════╝╚██╗██╔╝
14+
██║██╔██╗ ██║██║ ██║█████╗ ╚███╔╝
15+
██║██║╚██╗██║██║ ██║██╔══╝ ██╔██╗
16+
██║██║ ╚████║██████╔╝███████╗██╔╝ ██╗
17+
╚═╝╚═╝ ╚═══╝╚═════╝ ╚══════╝╚═╝ ╚═╝
18+
19+
██████╗██╗ ███████╗ █████╗ ███╗ ██╗██╗ ██╗██████╗
20+
██╔════╝██║ ██╔════╝██╔══██╗████╗ ██║██║ ██║██╔══██╗
21+
██║ ██║ █████╗ ███████║██╔██╗ ██║██║ ██║██████╔╝
22+
██║ ██║ ██╔══╝ ██╔══██║██║╚██╗██║██║ ██║██╔═══╝
23+
╚██████╗███████╗███████╗██║ ██║██║ ╚████║╚██████╔╝██║
24+
╚═════╝╚══════╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚═╝
25+
26+
27+
Copyright 2025 Darling Data, LLC
28+
https://www.erikdarling.com/
29+
30+
For usage and licensing details, run:
31+
EXECUTE sp_IndexCleanup
32+
@help = 1;
33+
34+
For working through errors:
35+
EXECUTE sp_IndexCleanup
36+
@debug = 1;
37+
38+
For support, head over to GitHub:
39+
https://code.erikdarling.com
40+
41+
*/
42+
43+
1044
IF OBJECT_ID('dbo.sp_IndexCleanup', 'P') IS NULL
1145
BEGIN
1246
EXECUTE ('CREATE PROCEDURE dbo.sp_IndexCleanup AS RETURN 138;');

0 commit comments

Comments
 (0)