diff --git a/Alerts/Alerts.sql b/Alerts/Alerts.sql index 1957ea5..7f9c924 100644 --- a/Alerts/Alerts.sql +++ b/Alerts/Alerts.sql @@ -11,7 +11,7 @@ GO This script will set up alerts for high severity and corruption errors in SQL Server. -Copyright 2024 Darling Data, LLC +Copyright 2025 Darling Data, LLC https://www.erikdarling.com/ For support, head over to GitHub: @@ -53,7 +53,7 @@ DECLARE RETURN; -EXEC msdb.dbo.sp_add_alert +EXECUTE msdb.dbo.sp_add_alert @name = N'Severity 019', @message_id = 0, @severity = 19, @@ -62,12 +62,12 @@ EXEC msdb.dbo.sp_add_alert @include_event_description_in = 1, @job_id = N'00000000-0000-0000-0000-000000000000'; -EXEC msdb.dbo.sp_add_notification +EXECUTE msdb.dbo.sp_add_notification @alert_name = N'Severity 019', @operator_name = @operator_name, @notification_method = 7; -EXEC msdb.dbo.sp_add_alert +EXECUTE msdb.dbo.sp_add_alert @name = N'Severity 020', @message_id = 0, @severity = 20, @@ -76,12 +76,12 @@ EXEC msdb.dbo.sp_add_alert @include_event_description_in = 1, @job_id = N'00000000-0000-0000-0000-000000000000'; -EXEC msdb.dbo.sp_add_notification +EXECUTE msdb.dbo.sp_add_notification @alert_name = N'Severity 020', @operator_name = @operator_name, @notification_method = 7; -EXEC msdb.dbo.sp_add_alert +EXECUTE msdb.dbo.sp_add_alert @name = N'Severity 021', @message_id = 0, @severity = 21, @@ -90,12 +90,12 @@ EXEC msdb.dbo.sp_add_alert @include_event_description_in = 1, @job_id = N'00000000-0000-0000-0000-000000000000'; -EXEC msdb.dbo.sp_add_notification +EXECUTE msdb.dbo.sp_add_notification @alert_name = N'Severity 021', @operator_name = @operator_name, @notification_method = 7; -EXEC msdb.dbo.sp_add_alert +EXECUTE msdb.dbo.sp_add_alert @name = N'Severity 022', @message_id = 0, @severity = 22, @@ -104,12 +104,12 @@ EXEC msdb.dbo.sp_add_alert @include_event_description_in = 1, @job_id = N'00000000-0000-0000-0000-000000000000'; -EXEC msdb.dbo.sp_add_notification +EXECUTE msdb.dbo.sp_add_notification @alert_name = N'Severity 022', @operator_name = @operator_name, @notification_method = 7; -EXEC msdb.dbo.sp_add_alert +EXECUTE msdb.dbo.sp_add_alert @name = N'Severity 023', @message_id = 0, @severity = 23, @@ -118,12 +118,12 @@ EXEC msdb.dbo.sp_add_alert @include_event_description_in = 1, @job_id = N'00000000-0000-0000-0000-000000000000'; -EXEC msdb.dbo.sp_add_notification +EXECUTE msdb.dbo.sp_add_notification @alert_name = N'Severity 023', @operator_name = @operator_name, @notification_method = 7; -EXEC msdb.dbo.sp_add_alert +EXECUTE msdb.dbo.sp_add_alert @name = N'Severity 024', @message_id = 0, @severity = 24, @@ -132,12 +132,12 @@ EXEC msdb.dbo.sp_add_alert @include_event_description_in = 1, @job_id = N'00000000-0000-0000-0000-000000000000'; -EXEC msdb.dbo.sp_add_notification +EXECUTE msdb.dbo.sp_add_notification @alert_name = N'Severity 024', @operator_name = @operator_name, @notification_method = 7; -EXEC msdb.dbo.sp_add_alert +EXECUTE msdb.dbo.sp_add_alert @name = N'Severity 025', @message_id = 0, @severity = 25, @@ -146,12 +146,12 @@ EXEC msdb.dbo.sp_add_alert @include_event_description_in = 1, @job_id = N'00000000-0000-0000-0000-000000000000'; -EXEC msdb.dbo.sp_add_notification +EXECUTE msdb.dbo.sp_add_notification @alert_name = N'Severity 025', @operator_name = @operator_name, @notification_method = 7; -EXEC msdb.dbo.sp_add_alert +EXECUTE msdb.dbo.sp_add_alert @name = N'Error Number 823', @message_id = 823, @severity = 0, @@ -160,12 +160,12 @@ EXEC msdb.dbo.sp_add_alert @include_event_description_in = 1, @job_id = N'00000000-0000-0000-0000-000000000000'; -EXEC msdb.dbo.sp_add_notification +EXECUTE msdb.dbo.sp_add_notification @alert_name = N'Error Number 823', @operator_name = @operator_name, @notification_method = 7; -EXEC msdb.dbo.sp_add_alert +EXECUTE msdb.dbo.sp_add_alert @name = N'Error Number 824', @message_id = 824, @severity = 0, @@ -174,12 +174,12 @@ EXEC msdb.dbo.sp_add_alert @include_event_description_in = 1, @job_id = N'00000000-0000-0000-0000-000000000000'; -EXEC msdb.dbo.sp_add_notification +EXECUTE msdb.dbo.sp_add_notification @alert_name = N'Error Number 824', @operator_name = @operator_name, @notification_method = 7; -EXEC msdb.dbo.sp_add_alert +EXECUTE msdb.dbo.sp_add_alert @name = N'Error Number 825', @message_id = 825, @severity = 0, @@ -188,7 +188,7 @@ EXEC msdb.dbo.sp_add_alert @include_event_description_in = 1, @job_id = N'00000000-0000-0000-0000-000000000000'; -EXEC msdb.dbo.sp_add_notification +EXECUTE msdb.dbo.sp_add_notification @alert_name = N'Error Number 825', @operator_name = @operator_name, @notification_method = 7; diff --git a/Clear Token Perm/ClearTokenPerm Agent Job.sql b/Clear Token Perm/ClearTokenPerm Agent Job.sql index cc9b66a..935ac67 100644 --- a/Clear Token Perm/ClearTokenPerm Agent Job.sql +++ b/Clear Token Perm/ClearTokenPerm Agent Job.sql @@ -16,7 +16,7 @@ For background on why you might need this: In short, if your security caches are growing out of control, it can cause all sorts of weird issues with SQL Server. -Copyright 2024 Darling Data, LLC +Copyright 2025 Darling Data, LLC https://www.erikdarling.com/ For support, head over to GitHub: @@ -52,7 +52,7 @@ IF NOT EXISTS AND category_class = 1 ) BEGIN - EXEC @ReturnCode = msdb.dbo.sp_add_category + EXECUTE @ReturnCode = msdb.dbo.sp_add_category @class = N'JOB', @type = N'LOCAL', @name = N'[Uncategorized (Local)]'; @@ -62,7 +62,7 @@ BEGIN END; -EXEC @ReturnCode = msdb.dbo.sp_add_job +EXECUTE @ReturnCode = msdb.dbo.sp_add_job @job_name = N'Clear Security Cache Every 30 Minutes', @enabled = 1, @notify_level_eventlog = 0, @@ -85,7 +85,7 @@ https://github.com/erikdarlingdata/DarlingData', IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback; -EXEC @ReturnCode = msdb.dbo.sp_add_jobstep +EXECUTE @ReturnCode = msdb.dbo.sp_add_jobstep @job_id = @jobId, @step_name = N'Execute dbo.ClearTokenPerm', @step_id = 1, @@ -98,7 +98,7 @@ EXEC @ReturnCode = msdb.dbo.sp_add_jobstep @retry_interval = 0, @os_run_priority = 0, @subsystem = N'TSQL', - @command = N'EXEC dbo.ClearTokenPerm + @command = N'EXECUTE dbo.ClearTokenPerm @CacheSizeGB = 1;', @database_name = N'master', @flags = 0; @@ -106,14 +106,14 @@ EXEC @ReturnCode = msdb.dbo.sp_add_jobstep IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback; -EXEC @ReturnCode = msdb.dbo.sp_update_job +EXECUTE @ReturnCode = msdb.dbo.sp_update_job @job_id = @jobId, @start_step_id = 1; IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback; -EXEC @ReturnCode = msdb.dbo.sp_add_jobschedule +EXECUTE @ReturnCode = msdb.dbo.sp_add_jobschedule @job_id = @jobId, @name = N'Clear Security Cache Every 30 Minutes', @enabled = 1, @@ -132,7 +132,7 @@ EXEC @ReturnCode = msdb.dbo.sp_add_jobschedule IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback; -EXEC @ReturnCode = msdb.dbo.sp_add_jobserver +EXECUTE @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @jobId, @server_name = N'(local)'; diff --git a/Clear Token Perm/ClearTokenPerm.sql b/Clear Token Perm/ClearTokenPerm.sql index 519975a..5a6497d 100644 --- a/Clear Token Perm/ClearTokenPerm.sql +++ b/Clear Token Perm/ClearTokenPerm.sql @@ -16,7 +16,7 @@ For background on why you might need this: In short, if your security caches are growing out of control, it can cause all sorts of weird issues with SQL Server. -Copyright 2024 Darling Data, LLC +Copyright 2025 Darling Data, LLC https://www.erikdarling.com/ For support, head over to GitHub: @@ -48,7 +48,7 @@ SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; DECLARE @clear_triggered bit = 0; -IF OBJECT_ID(N'dbo.ClearTokenPermLogging') IS NULL +IF OBJECT_ID(N'dbo.ClearTokenPermLogging', N'U') IS NULL BEGIN CREATE TABLE dbo.ClearTokenPermLogging @@ -70,8 +70,8 @@ IF (domc.pages_kb / 1024. / 1024.) ) FROM sys.dm_os_memory_clerks AS domc - WHERE domc.type = 'USERSTORE_TOKENPERM' - AND domc.name = 'TokenAndPermUserStore' + WHERE domc.type = N'USERSTORE_TOKENPERM' + AND domc.name = N'TokenAndPermUserStore' ) >= @CacheSizeGB BEGIN INSERT @@ -93,8 +93,8 @@ BEGIN clear_triggered = 1 FROM sys.dm_os_memory_clerks AS domc - WHERE domc.type = 'USERSTORE_TOKENPERM' - AND domc.name = 'TokenAndPermUserStore'; + WHERE domc.type = N'USERSTORE_TOKENPERM' + AND domc.name = N'TokenAndPermUserStore'; DBCC FREESYSTEMCACHE('TokenAndPermUserStore'); END; @@ -119,14 +119,14 @@ BEGIN clear_triggered = 0 FROM sys.dm_os_memory_clerks AS domc - WHERE domc.type = 'USERSTORE_TOKENPERM' - AND domc.name = 'TokenAndPermUserStore'; + WHERE domc.type = N'USERSTORE_TOKENPERM' + AND domc.name = N'TokenAndPermUserStore'; END; END; RETURN; /*Example execution*/ -EXEC dbo.ClearTokenPerm +EXECUTE dbo.ClearTokenPerm @CacheSizeGB = 1; /*Query a log*/ diff --git a/Clear Token Perm/Inflate Security Cache Demo And Analysis Script.sql b/Clear Token Perm/Inflate Security Cache Demo And Analysis Script.sql index 2b5aea1..0f2474b 100644 --- a/Clear Token Perm/Inflate Security Cache Demo And Analysis Script.sql +++ b/Clear Token Perm/Inflate Security Cache Demo And Analysis Script.sql @@ -21,7 +21,7 @@ https://github.com/erikdarlingdata/DarlingData MIT License -Copyright 2024 Darling Data, LLC +Copyright 2025 Darling Data, LLC https://www.erikdarling.com/ @@ -71,7 +71,7 @@ END; WHILE @counter < 50000 BEGIN - EXEC sys.sp_setapprole + EXECUTE sys.sp_setapprole @rolename = N'your_terrible_app', @password = N'y0ur_t3rr1bl3_4pp', @fCreateCookie = true, @@ -80,7 +80,7 @@ BEGIN SELECT @bl0b_eater = USER_NAME(); - EXEC sys.sp_unsetapprole + EXECUTE sys.sp_unsetapprole @cronut; SELECT @@ -174,9 +174,9 @@ SELECT token_name = c.c.value('@name', 'varchar(50)'), principal_id = - c.c.value('@id', 'int'), + c.c.value('@id', 'integer'), database_id = - c.c.value('@dbid', 'int'), + c.c.value('@dbid', 'integer'), time_stamp = c.c.value('@timestamp', 'bigint') INTO #tapus @@ -204,7 +204,7 @@ SELECT FROM #tapus AS t INNER JOIN sys.server_principals AS p ON t.principal_id = p.principal_id -WHERE t.token_name = 'SecContextToken' +WHERE t.token_name = N'SecContextToken' GROUP BY p.name ORDER BY @@ -219,8 +219,8 @@ SELECT FROM #tapus AS t INNER JOIN sys.databases AS d ON d.database_id = t.database_id -WHERE t.token_name = 'UserToken' -AND t.cache_name = 'TokenAndPermUserStore' +WHERE t.token_name = N'UserToken' +AND t.cache_name = N'TokenAndPermUserStore' GROUP BY d.name ORDER BY @@ -235,7 +235,7 @@ SELECT FROM #tapus AS t INNER JOIN sys.databases AS d ON d.database_id = t.database_id -WHERE t.token_name = 'UserToken' +WHERE t.token_name = N'UserToken' GROUP BY d.name ORDER BY diff --git a/Create Long IN List/Longingly.sql b/Create Long IN List/Longingly.sql index 6f18508..53bcea9 100644 --- a/Create Long IN List/Longingly.sql +++ b/Create Long IN List/Longingly.sql @@ -13,7 +13,7 @@ GO This procedure exists only to show how long IN clauses can hurt query performance. -Copyright 2024 Darling Data, LLC +Copyright 2025 Darling Data, LLC https://www.erikdarling.com/ For support, head over to GitHub: diff --git a/Dynamic SQL Logging/Dynamic SQL Logging.sql b/Dynamic SQL Logging/Dynamic SQL Logging.sql index 60ff2ae..82c2ac7 100644 --- a/Dynamic SQL Logging/Dynamic SQL Logging.sql +++ b/Dynamic SQL Logging/Dynamic SQL Logging.sql @@ -13,7 +13,7 @@ GO Stored procedure to be used for logging performance information from dynamic SQL -Copyright (c) 2024 Darling Data, LLC +Copyright (c) 2025 Darling Data, LLC https://www.erikdarling.com/ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -32,7 +32,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. CREATE OR ALTER PROCEDURE dbo.logging ( - @spid int, + @spid integer, @sql nvarchar(MAX), @query_plan xml, @guid_in uniqueidentifier, diff --git a/Helper Views/WhatsUpIndexes.sql b/Helper Views/WhatsUpIndexes.sql index 34bac21..605b9c7 100644 --- a/Helper Views/WhatsUpIndexes.sql +++ b/Helper Views/WhatsUpIndexes.sql @@ -14,7 +14,7 @@ This is a quick one-off script I use in some presentations to look at index size https://github.com/erikdarlingdata/DarlingData -Copyright (c) 2024 Darling Data, LLC +Copyright (c) 2025 Darling Data, LLC https://www.erikdarling.com/ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, @@ -26,7 +26,7 @@ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMA CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -IF OBJECT_ID(N'dbo.WhatsUpIndexes') IS NULL +IF OBJECT_ID(N'dbo.WhatsUpIndexes', N'IF') IS NULL BEGIN DECLARE @vsql nvarchar(MAX) = N' @@ -37,7 +37,7 @@ BEGIN x = 138;'; PRINT @vsql; - EXEC (@vsql); + EXECUTE (@vsql); END; GO diff --git a/Helper Views/WhatsUpLocks.sql b/Helper Views/WhatsUpLocks.sql index efbe529..215085d 100644 --- a/Helper Views/WhatsUpLocks.sql +++ b/Helper Views/WhatsUpLocks.sql @@ -15,7 +15,7 @@ It's definitely not a replacement for sp_WhoIsActive, it just gives me what I ca https://github.com/erikdarlingdata/DarlingData -Copyright (c) 2024 Darling Data, LLC +Copyright (c) 2025 Darling Data, LLC https://www.erikdarling.com/ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, @@ -27,7 +27,7 @@ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMA CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -IF OBJECT_ID(N'dbo.WhatsUpLocks') IS NULL +IF OBJECT_ID(N'dbo.WhatsUpLocks', N'IF') IS NULL BEGIN DECLARE @fsql nvarchar(MAX) = N' @@ -40,26 +40,21 @@ BEGIN x = 138;'; PRINT @fsql; - EXEC (@fsql); + EXECUTE (@fsql); END; GO ALTER FUNCTION dbo.WhatsUpLocks ( - @spid int + @spid integer ) RETURNS table AS RETURN -SELECT +SELECT TOP (9223372036854775807) dtl.request_mode, - locked_object = - CASE dtl.resource_type - WHEN N'OBJECT' - THEN OBJECT_NAME(dtl.resource_associated_entity_id) - ELSE OBJECT_NAME(p.object_id) - END, + l.locked_object, index_name = ISNULL(i.name, N'OBJECT'), dtl.resource_type, @@ -74,6 +69,16 @@ SELECT 0 ) ), + object_locks = + SUM + ( + IIF + ( + dtl.resource_type = N'OBJECT', + 1, + 0 + ) + ), page_locks = SUM ( @@ -98,26 +103,43 @@ SELECT COUNT_BIG(*) FROM sys.dm_tran_locks AS dtl WITH(NOLOCK) LEFT JOIN sys.partitions AS p WITH(NOLOCK) - ON p.hobt_id = dtl.resource_associated_entity_id + ON dtl.resource_associated_entity_id = p.hobt_id +OUTER APPLY +( + SELECT + locked_object = ao.name + FROM sys.all_objects AS ao + WHERE dtl.resource_type = N'OBJECT' + AND dtl.resource_associated_entity_id = ao.object_id + + UNION ALL + + SELECT + locked_object = ao.name + FROM sys.all_objects AS ao + WHERE dtl.resource_type <> N'OBJECT' + AND p.object_id = ao.object_id +) AS l OUTER APPLY ( SELECT TOP (1) i.name FROM sys.indexes AS i WITH(NOLOCK) - WHERE p.object_id = i.object_id - AND p.index_id = i.index_id + WHERE i.object_id = p.object_id + AND i.index_id = p.index_id ) AS i WHERE (dtl.request_session_id = @spid OR @spid IS NULL) AND dtl.resource_type <> N'DATABASE' AND dtl.request_request_id = CURRENT_REQUEST_ID() AND dtl.request_owner_id = CURRENT_TRANSACTION_ID() +AND l.locked_object <> N'WhatsUpLocks' GROUP BY - CASE dtl.resource_type - WHEN N'OBJECT' - THEN OBJECT_NAME(dtl.resource_associated_entity_id) - ELSE OBJECT_NAME(p.object_id) - END, + l.locked_object, i.name, dtl.resource_type, dtl.request_mode, - dtl.request_status; \ No newline at end of file + dtl.request_status +ORDER BY + l.locked_object, + index_name, + total_locks DESC; \ No newline at end of file diff --git a/Helper Views/WhatsUpMemory.sql b/Helper Views/WhatsUpMemory.sql index 41c0c38..ae5c858 100644 --- a/Helper Views/WhatsUpMemory.sql +++ b/Helper Views/WhatsUpMemory.sql @@ -17,7 +17,7 @@ The dm_os_buffer_descriptors DMV especially can be really slow at times https://github.com/erikdarlingdata/DarlingData -Copyright (c) 2024 Darling Data, LLC +Copyright (c) 2025 Darling Data, LLC https://www.erikdarling.com/ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, @@ -30,7 +30,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -IF OBJECT_ID(N'dbo.WhatsUpMemory') IS NULL +IF OBJECT_ID(N'dbo.WhatsUpMemory', N'IF') IS NULL BEGIN DECLARE @vsql nvarchar(MAX) = N' @@ -41,7 +41,7 @@ BEGIN x = 138;'; PRINT @vsql; - EXEC (@vsql); + EXECUTE (@vsql); END; GO diff --git a/Helper Views/tempdb_tester.sql b/Helper Views/tempdb_tester.sql index 020c02a..8aa6c80 100644 --- a/Helper Views/tempdb_tester.sql +++ b/Helper Views/tempdb_tester.sql @@ -13,7 +13,7 @@ GO This generates some semi-random tempdb activity -Copyright 2024 Darling Data, LLC +Copyright 2025 Darling Data, LLC https://www.erikdarling.com/ For support, head over to GitHub: diff --git a/Ola Stats Only Job/Ola Stats Only Job.sql b/Ola Stats Only Job/Ola Stats Only Job.sql index 36a7d12..b7fae94 100644 --- a/Ola Stats Only Job/Ola Stats Only Job.sql +++ b/Ola Stats Only Job/Ola Stats Only Job.sql @@ -29,7 +29,7 @@ If you're using a version older than that, I feel sorry for your mother. Ola's scripts and licensing information is available here: * https://github.com/olahallengren/sql-server-maintenance-solution -Copyright (c) 2024 Darling Data, LLC +Copyright (c) 2025 Darling Data, LLC https://www.erikdarling.com/ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, @@ -51,9 +51,9 @@ GO BEGIN TRANSACTION; DECLARE - @ReturnCode int = 0, + @ReturnCode integer = 0, @jobId binary(16), - @active_start_date int = (SELECT CONVERT(int, CONVERT(varchar(35), GETDATE(), 112))), + @active_start_date int = (SELECT CONVERT(integer, CONVERT(varchar(35), GETDATE(), 112))), @schedule_uid nvarchar(36) = NEWID(); @@ -66,7 +66,7 @@ IF NOT EXISTS AND category_class = 1 ) BEGIN - EXEC @ReturnCode = msdb.dbo.sp_add_category + EXECUTE @ReturnCode = msdb.dbo.sp_add_category @class = N'JOB', @type = N'LOCAL', @name = N'[Uncategorized (Local)]'; @@ -75,7 +75,7 @@ BEGIN GOTO QuitWithRollback; END; -EXEC @ReturnCode = msdb.dbo.sp_add_job +EXECUTE @ReturnCode = msdb.dbo.sp_add_job @job_name = N'IndexOptimize - STATISTICS_ONLY', @enabled = 1, @notify_level_eventlog = 0, @@ -91,7 +91,7 @@ EXEC @ReturnCode = msdb.dbo.sp_add_job IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback; -EXEC @ReturnCode = msdb.dbo.sp_add_jobstep +EXECUTE @ReturnCode = msdb.dbo.sp_add_jobstep @job_id = @jobId, @step_name = N'Update Statistics', @step_id = 1, @@ -104,20 +104,20 @@ EXEC @ReturnCode = msdb.dbo.sp_add_jobstep @retry_interval = 0, @os_run_priority = 0, @subsystem = N'TSQL', - @command = N'EXECUTE dbo.IndexOptimize @Databases = ''USER_DATABASES'', @FragmentationLow = NULL, @FragmentationMedium = NULL, @FragmentationHigh = NULL, @UpdateStatistics = ''ALL'', @StatisticsModificationLevel = 5, @MinNumberOfPages = 50000, @LogToTable = ''Y'';', + @command = N'EXECUTE dbo.IndexOptimize @Databases = ''USER_DATABASES'', @FragmentationLow = NULL, @FragmentationMedium = NULL, @FragmentationHigh = NULL, @UpdateStatistics = ''ALL'', @StatisticsModificationLevel = 5, @LogToTable = ''Y'';', @flags = 0; IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback; -EXEC @ReturnCode = msdb.dbo.sp_update_job +EXECUTE @ReturnCode = msdb.dbo.sp_update_job @job_id = @jobId, @start_step_id = 1; IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback; -EXEC @ReturnCode = msdb.dbo.sp_add_jobschedule +EXECUTE @ReturnCode = msdb.dbo.sp_add_jobschedule @job_id = @jobId, @name = N'Nightly Statistics Update', @enabled = 1, @@ -136,7 +136,7 @@ EXEC @ReturnCode = msdb.dbo.sp_add_jobschedule IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback; - EXEC @ReturnCode = msdb.dbo.sp_add_jobserver + EXECUTE @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @jobId, @server_name = N'(local)'; diff --git a/SQL Debug Example/DebugExample.sql b/SQL Debug Example/DebugExample.sql index 1a2d587..7e3e3e1 100644 --- a/SQL Debug Example/DebugExample.sql +++ b/SQL Debug Example/DebugExample.sql @@ -1,6 +1,6 @@ /* -Copyright 2024 Darling Data, LLC +Copyright 2025 Darling Data, LLC https://www.erikdarling.com/ */ @@ -8,9 +8,9 @@ https://www.erikdarling.com/ CREATE OR ALTER PROCEDURE dbo.DebugExample ( - @debug_logic bit = 0, - @debug_performance bit = 0, - @execute_sql bit = 1 + @debug_logic bit = 'false', + @debug_performance bit = 'false', + @execute_sql bit = 'true' ) AS BEGIN diff --git a/Stack Column Store Database/MakeBigStackCCS.sql b/Stack Column Store Database/MakeBigStackCCS.sql index bb03531..5570b24 100644 --- a/Stack Column Store Database/MakeBigStackCCS.sql +++ b/Stack Column Store Database/MakeBigStackCCS.sql @@ -1,7 +1,7 @@ /* MIT License -Copyright (c) 2024 Darling Data, LLC +Copyright (c) 2025 Darling Data, LLC https://www.erikdarling.com/ @@ -33,13 +33,13 @@ SOFTWARE. Example executions -EXEC dbo.make_big_stack_cs +EXECUTE dbo.make_big_stack_cs @loops = 25, @truncate_tables = 1, @count_when_done = 1, @rebuild_when_done = 1; -EXEC dbo.make_big_stack_cs +EXECUTE dbo.make_big_stack_cs @loops = 25, @truncate_tables = 0, @count_when_done = 1, diff --git a/Stack Column Store Database/Script StackOverflowCS.sql b/Stack Column Store Database/Script StackOverflowCS.sql index fc90a35..939e43c 100644 --- a/Stack Column Store Database/Script StackOverflowCS.sql +++ b/Stack Column Store Database/Script StackOverflowCS.sql @@ -1,7 +1,7 @@ /* MIT License -Copyright (c) 2024 Darling Data, LLC +Copyright (c) 2025 Darling Data, LLC https://www.erikdarling.com/ @@ -78,7 +78,7 @@ GO IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled')) BEGIN - EXEC StackOverflowCS.sys.sp_fulltext_database @action = 'enable'; + EXECUTE StackOverflowCS.sys.sp_fulltext_database @action = 'enable'; END; GO ALTER DATABASE StackOverflowCS SET ANSI_NULL_DEFAULT OFF; diff --git a/String Functions/get_letters.sql b/String Functions/get_letters.sql index 9d13acb..3c922c0 100644 --- a/String Functions/get_letters.sql +++ b/String Functions/get_letters.sql @@ -13,8 +13,8 @@ AS For support: https://github.com/erikdarlingdata/DarlingData -Copyright 2023 Darling Data, LLC -https://erikdarlingdata.com +Copyright 2025 Darling Data, LLC +https://erikdarling.com MIT LICENSE @@ -81,8 +81,8 @@ AS For support: https://github.com/erikdarlingdata/DarlingData -Copyright 2023 Darling Data, LLC -https://erikdarlingdata.com +Copyright 2025 Darling Data, LLC +https://erikdarling.com MIT LICENSE diff --git a/String Functions/get_numbers.sql b/String Functions/get_numbers.sql index 9be87a3..48e9663 100644 --- a/String Functions/get_numbers.sql +++ b/String Functions/get_numbers.sql @@ -13,8 +13,8 @@ AS For support: https://github.com/erikdarlingdata/DarlingData -Copyright 2023 Darling Data, LLC -https://erikdarlingdata.com +Copyright 2025 Darling Data, LLC +https://erikdarling.com MIT LICENSE @@ -82,8 +82,8 @@ AS For support: https://github.com/erikdarlingdata/DarlingData -Copyright 2023 Darling Data, LLC -https://erikdarlingdata.com +Copyright 2025 Darling Data, LLC +https://erikdarling.com MIT LICENSE diff --git a/String Functions/strip_characters.sql b/String Functions/strip_characters.sql index f06514f..a6fb4e0 100644 --- a/String Functions/strip_characters.sql +++ b/String Functions/strip_characters.sql @@ -14,8 +14,8 @@ AS For support: https://github.com/erikdarlingdata/DarlingData -Copyright 2023 Darling Data, LLC -https://erikdarlingdata.com +Copyright 2025 Darling Data, LLC +https://erikdarling.com MIT LICENSE @@ -84,8 +84,8 @@ AS For support: https://github.com/erikdarlingdata/DarlingData -Copyright 2023 Darling Data, LLC -https://erikdarlingdata.com +Copyright 2025 Darling Data, LLC +https://erikdarling.com MIT LICENSE diff --git a/sp_HealthParser/sp_HealthParser.sql b/sp_HealthParser/sp_HealthParser.sql index b37b2a8..51425e6 100644 --- a/sp_HealthParser/sp_HealthParser.sql +++ b/sp_HealthParser/sp_HealthParser.sql @@ -34,7 +34,7 @@ https://github.com/erikdarlingdata/DarlingData IF OBJECT_ID('dbo.sp_HealthParser') IS NULL BEGIN - EXEC ('CREATE PROCEDURE dbo.sp_HealthParser AS RETURN 138;'); + EXECUTE ('CREATE PROCEDURE dbo.sp_HealthParser AS RETURN 138;'); END; GO @@ -487,7 +487,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ( wait_info ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql, @params, @start_date, @@ -533,7 +533,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ( sp_server_diagnostics_component_result ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql, @params, @start_date, @@ -589,7 +589,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ( xml_deadlock_report ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql, @params, @start_date, @@ -655,7 +655,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ( wait_info ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql, @params, @start_date, @@ -705,7 +705,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ( sp_server_diagnostics_component_result ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql, @params, @start_date, @@ -763,7 +763,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ( xml_deadlock_report ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql, @params, @start_date, diff --git a/sp_HumanEvents/Examples.sql b/sp_HumanEvents/Examples.sql index 18891cd..297d812 100644 --- a/sp_HumanEvents/Examples.sql +++ b/sp_HumanEvents/Examples.sql @@ -1,5 +1,5 @@ /* -Copyright 2024 Darling Data, LLC +Copyright 2025 Darling Data, LLC https://www.erikdarling.com/ For support, head over to GitHub: @@ -24,7 +24,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- To capture all types of β€œcompleted” queries that have run for at least one second, for 20 seconds, from a specific database -EXEC dbo.sp_HumanEvents +EXECUTE dbo.sp_HumanEvents @event_type = 'query', @query_duration_ms = 1000, @seconds_sample = 20, @@ -32,7 +32,7 @@ EXEC dbo.sp_HumanEvents -- Maybe you want to filter out queries that have asked for a bit of memory: -EXEC dbo.sp_HumanEvents +EXECUTE dbo.sp_HumanEvents @event_type = 'query', @query_duration_ms = 1000, @seconds_sample = 20, @@ -40,7 +40,7 @@ EXEC dbo.sp_HumanEvents -- Or maybe you want to find unparameterized queries from a poorly written app that constructs strings in ugly ways, but it generates a lot of queries so you only want data on about a third of them. -EXEC dbo.sp_HumanEvents +EXECUTE dbo.sp_HumanEvents @event_type = 'compilations', @client_app_name = N'GL00SNIFΠ―', @session_id = 'sample', @@ -48,20 +48,20 @@ EXEC dbo.sp_HumanEvents -- Perhaps you think queries recompiling are the cause of your problems! Heck, they might be. Have you tried removing recompile hints? 😁 -EXEC dbo.sp_HumanEvents +EXECUTE dbo.sp_HumanEvents @event_type = 'recompilations', @seconds_sample = 30; -- Look, blocking is annoying. Just turn on RCSI, you goblin. Unless you’re not allowed to. -EXEC dbo.sp_HumanEvents +EXECUTE dbo.sp_HumanEvents @event_type = 'blocking', @seconds_sample = 60, @blocking_duration_ms = 5000; -- If you want to track wait stats, this’ll work pretty well. Keep in mind β€œall” is a focused list of β€œinteresting” waits to queries, not every wait stat. -EXEC dbo.sp_HumanEvents +EXECUTE dbo.sp_HumanEvents @event_type = 'waits', @wait_duration_ms = 10, @seconds_sample = 100, @@ -69,7 +69,7 @@ EXEC dbo.sp_HumanEvents -- Note that THREADPOOL is SOS_WORKER in xe-land. why? I dunno. -EXEC dbo.sp_HumanEvents +EXECUTE dbo.sp_HumanEvents @event_type = 'waits', @wait_duration_ms = 100, @seconds_sample = 10, @@ -79,7 +79,7 @@ EXEC dbo.sp_HumanEvents -- For example, if you run this command: -EXEC sp_HumanEvents +EXECUTE sp_HumanEvents @event_type = N'query', @query_duration_ms = 1; @@ -93,7 +93,7 @@ EXEC sp_HumanEvents -- You need to use this command instead: -EXEC sp_HumanEvents +EXECUTE sp_HumanEvents @event_type = N'query', @query_duration_ms = 1, @gimme_danger = 1; @@ -103,24 +103,24 @@ EXEC sp_HumanEvents -- First, you need to set up permanent sessions to collect data. You can use commands like these to do that, but I urge you to add some filters like above to cut down on the data collected. On busy servers, over-collection can cause performance issues. -EXEC sp_HumanEvents +EXECUTE sp_HumanEvents @event_type = N'compiles', @keep_alive = 1; -EXEC sp_HumanEvents +EXECUTE sp_HumanEvents @event_type = N'recompiles', @keep_alive = 1; -EXEC sp_HumanEvents +EXECUTE sp_HumanEvents @event_type = N'query', @keep_alive = 1; -EXEC sp_HumanEvents +EXECUTE sp_HumanEvents @event_type = N'waits', @keep_alive = 1; -EXEC sp_HumanEvents +EXECUTE sp_HumanEvents @event_type = N'blocking', @keep_alive = 1; @@ -128,7 +128,7 @@ EXEC sp_HumanEvents -- Once your sessions are set up, this is the command to tell sp_HumanEvents which database and schema to log data to. -- Table names are created internally, so don’t worry about those. -EXEC sp_HumanEvents +EXECUTE sp_HumanEvents @output_database_name = N'YourDatabase', @output_schema_name = N'dbo'; diff --git a/sp_HumanEvents/sp_Human Events Agent Job Example.sql b/sp_HumanEvents/sp_Human Events Agent Job Example.sql index b646b4d..c81a9ae 100644 --- a/sp_HumanEvents/sp_Human Events Agent Job Example.sql +++ b/sp_HumanEvents/sp_Human Events Agent Job Example.sql @@ -7,7 +7,7 @@ Remember to scroll down and replace the database and schema names you want to us */ /* -Copyright 2024 Darling Data, LLC +Copyright 2025 Darling Data, LLC https://www.erikdarling.com/ For support, head over to GitHub: @@ -31,9 +31,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. BEGIN TRANSACTION; DECLARE - @ReturnCode int = 0, + @ReturnCode integer = 0, @jobId binary(16), - @active_start_date int = (SELECT CONVERT(int, CONVERT(varchar(35), GETDATE(), 112))), + @active_start_date int = (SELECT CONVERT(integer, CONVERT(varchar(35), GETDATE(), 112))), @schedule_uid nvarchar(36) = NEWID(); diff --git a/sp_HumanEvents/sp_HumanEvents.sql b/sp_HumanEvents/sp_HumanEvents.sql index 23a857e..0aa1c48 100644 --- a/sp_HumanEvents/sp_HumanEvents.sql +++ b/sp_HumanEvents/sp_HumanEvents.sql @@ -28,11 +28,11 @@ Copyright 2025 Darling Data, LLC https://www.erikdarling.com/ For usage and licensing details, run: -EXEC sp_HumanEvents +EXECUTE sp_HumanEvents @help = 1; For working through errors: -EXEC sp_HumanEvents +EXECUTE sp_HumanEvents @debug = 1; For support, head over to GitHub: @@ -42,7 +42,7 @@ https://github.com/erikdarlingdata/DarlingData IF OBJECT_ID('dbo.sp_HumanEvents') IS NULL BEGIN - EXEC ('CREATE PROCEDURE dbo.sp_HumanEvents AS RETURN 138;'); + EXECUTE ('CREATE PROCEDURE dbo.sp_HumanEvents AS RETURN 138;'); END; GO @@ -249,40 +249,40 @@ BEGIN SELECT N'this is handled dynamically, but please don''t think you''re crazy if one "doesn''t work"' UNION ALL SELECT N'to capture all types of "completed" queries that have run for at least one second for 20 seconds from a specific database' UNION ALL SELECT REPLICATE(N'-', 100) UNION ALL - SELECT N'EXEC dbo.sp_HumanEvents @event_type = ''query'', @query_duration_ms = 1000, @seconds_sample = 20, @database_name = ''YourMom'';' UNION ALL + SELECT N'EXECUTE dbo.sp_HumanEvents @event_type = ''query'', @query_duration_ms = 1000, @seconds_sample = 20, @database_name = ''YourMom'';' UNION ALL SELECT REPLICATE(N'-', 100) UNION ALL SELECT N'or that have asked for 1gb of memory' UNION ALL SELECT REPLICATE(N'-', 100) UNION ALL - SELECT N'EXEC dbo.sp_HumanEvents @event_type = ''query'', @query_duration_ms = 1000, @seconds_sample = 20, @requested_memory_mb = 1024;' UNION ALL + SELECT N'EXECUTE dbo.sp_HumanEvents @event_type = ''query'', @query_duration_ms = 1000, @seconds_sample = 20, @requested_memory_mb = 1024;' UNION ALL SELECT REPLICATE(N'-', 100) UNION ALL SELECT N'maybe you want to find unparameterized queries from a poorly written app' UNION ALL SELECT N'newer versions will use sql_statement_post_compile, older versions will use uncached_sql_batch_statistics and sql_statement_recompile' UNION ALL SELECT REPLICATE(N'-', 100) UNION ALL - SELECT N'EXEC dbo.sp_HumanEvents @event_type = ''compilations'', @client_app_name = N''GL00SNIFΠ―'', @session_id = ''sample'', @sample_divisor = 3;' UNION ALL + SELECT N'EXECUTE dbo.sp_HumanEvents @event_type = ''compilations'', @client_app_name = N''GL00SNIFΠ―'', @session_id = ''sample'', @sample_divisor = 3;' UNION ALL SELECT REPLICATE(N'-', 100) UNION ALL SELECT N'perhaps you think queries recompiling are the cause of your problems!' UNION ALL SELECT REPLICATE(N'-', 100) UNION ALL - SELECT N'EXEC dbo.sp_HumanEvents @event_type = ''recompilations'', @seconds_sample = 30;' UNION ALL + SELECT N'EXECUTE dbo.sp_HumanEvents @event_type = ''recompilations'', @seconds_sample = 30;' UNION ALL SELECT REPLICATE(N'-', 100) UNION ALL SELECT N'look, blocking is annoying. just turn on RCSI, you goblin.' UNION ALL SELECT REPLICATE(N'-', 100) UNION ALL - SELECT N'EXEC dbo.sp_HumanEvents @event_type = ''blocking'', @seconds_sample = 60, @blocking_duration_ms = 5000;' UNION ALL + SELECT N'EXECUTE dbo.sp_HumanEvents @event_type = ''blocking'', @seconds_sample = 60, @blocking_duration_ms = 5000;' UNION ALL SELECT REPLICATE(N'-', 100) UNION ALL SELECT N'i mean wait stats are probably a meme but whatever' UNION ALL SELECT REPLICATE(N'-', 100) UNION ALL - SELECT N'EXEC dbo.sp_HumanEvents @event_type = ''waits'', @wait_duration_ms = 10, @seconds_sample = 100, @wait_type = N''all'';' UNION ALL + SELECT N'EXECUTE dbo.sp_HumanEvents @event_type = ''waits'', @wait_duration_ms = 10, @seconds_sample = 100, @wait_type = N''all'';' UNION ALL SELECT REPLICATE(N'-', 100) UNION ALL SELECT N'note that THREADPOOL is SOS_WORKER in xe-land. why? i dunno.' UNION ALL SELECT REPLICATE(N'-', 100) UNION ALL - SELECT N'EXEC dbo.sp_HumanEvents @event_type = ''waits'', @wait_duration_ms = 10, @seconds_sample = 100, @wait_type = N''SOS_WORKER,RESOURCE_SEMAPHORE,YOUR_MOM'';' UNION ALL + SELECT N'EXECUTE dbo.sp_HumanEvents @event_type = ''waits'', @wait_duration_ms = 10, @seconds_sample = 100, @wait_type = N''SOS_WORKER,RESOURCE_SEMAPHORE,YOUR_MOM'';' UNION ALL SELECT REPLICATE(N'-', 100) UNION ALL SELECT N'to set up a permanent session for compiles, but you can specify any of the session types here' UNION ALL SELECT REPLICATE(N'-', 100) UNION ALL - SELECT N'EXEC sp_HumanEvents @event_type = N''compiles'', @debug = 1, @keep_alive = 1;' UNION ALL + SELECT N'EXECUTE sp_HumanEvents @event_type = N''compiles'', @debug = 1, @keep_alive = 1;' UNION ALL SELECT REPLICATE(N'-', 100) UNION ALL SELECT N'to log to a database named whatever, and a schema called dbo' UNION ALL SELECT REPLICATE(N'-', 100) UNION ALL - SELECT N'EXEC sp_HumanEvents @debug = 1, @output_database_name = N''whatever'', @output_schema_name = N''dbo'';' UNION ALL + SELECT N'EXECUTE sp_HumanEvents @debug = 1, @output_database_name = N''whatever'', @output_schema_name = N''dbo'';' UNION ALL SELECT REPLICATE(N'-', 100); @@ -624,7 +624,7 @@ BEGIN WHILE @@FETCH_STATUS = 0 BEGIN PRINT @drop_old_sql; - EXEC (@drop_old_sql); + EXECUTE (@drop_old_sql); FETCH NEXT FROM @drop_cursor @@ -1030,8 +1030,8 @@ AND EXISTS ) BEGIN RAISERROR(N'You need to set up the blocked process report in order to use this: - EXEC sys.sp_configure ''show advanced options'', 1; - EXEC sys.sp_configure ''blocked process threshold'', 5; /* Seconds of blocking before a report is generated */ + EXECUTE sys.sp_configure ''show advanced options'', 1; + EXECUTE sys.sp_configure ''blocked process threshold'', 5; /* Seconds of blocking before a report is generated */ RECONFIGURE;', 11, 0) WITH NOWAIT; RETURN; @@ -1097,7 +1097,7 @@ BEGIN BEGIN RAISERROR(N'A session with the name %s already exists. dropping.', 0, 1, @session_name) WITH NOWAIT; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @drop_sql; END; END; @@ -1115,7 +1115,7 @@ BEGIN BEGIN RAISERROR(N'A session with the name %s already exists. dropping.', 0, 1, @session_name) WITH NOWAIT; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @drop_sql; END; END; @@ -1146,7 +1146,7 @@ BEGIN @s_params = N'@is_out integer OUTPUT'; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @s_sql, @s_params, @is_out = @s_out OUTPUT; @@ -1699,11 +1699,11 @@ SET @session_sql += SET @session_sql += @session_with; IF @debug = 1 BEGIN RAISERROR(@session_sql, 0, 1) WITH NOWAIT; END; -EXEC (@session_sql); +EXECUTE (@session_sql); /* This starts the event session */ IF @debug = 1 BEGIN RAISERROR(@start_sql, 0, 1) WITH NOWAIT; END; -EXEC (@start_sql); +EXECUTE (@start_sql); /* bail out here if we want to keep the session */ IF @keep_alive = 1 @@ -3415,11 +3415,11 @@ IF @keep_alive = 0 BEGIN IF @debug = 1 BEGIN RAISERROR(@stop_sql, 0, 1) WITH NOWAIT; END; RAISERROR(N'all done, stopping session', 0, 1) WITH NOWAIT; - EXEC (@stop_sql); + EXECUTE (@stop_sql); IF @debug = 1 BEGIN RAISERROR(@drop_sql, 0, 1) WITH NOWAIT; END; RAISERROR(N'and dropping session', 0, 1) WITH NOWAIT; - EXEC (@drop_sql); + EXECUTE (@drop_sql); END; RETURN; @@ -3494,7 +3494,7 @@ BEGIN IF @debug = 1 BEGIN RAISERROR(@the_sleeper_must_awaken, 0, 1) WITH NOWAIT; END; RAISERROR(N'Starting keeper_HumanEvents... inactive sessions', 0, 1) WITH NOWAIT; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @the_sleeper_must_awaken; END; @@ -3720,7 +3720,7 @@ BEGIN END; IF @debug = 1 BEGIN RAISERROR(@table_sql, 0, 1) WITH NOWAIT; END; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @table_sql; RAISERROR(N'Updating #human_events_worker to set is_table_created for %s', 0, 1, @event_type_check) WITH NOWAIT; @@ -3950,7 +3950,7 @@ BEGIN END; RAISERROR(N'creating view %s', 0, 1, @event_type_check) WITH NOWAIT; - EXEC @spe @view_sql; + EXECUTE @spe @view_sql; IF @debug = 1 BEGIN RAISERROR(N'@min_id: %i', 0, 1, @min_id) WITH NOWAIT; END; @@ -4547,7 +4547,7 @@ ORDER BY END; /* this executes the insert */ - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @table_sql, N'@date_filter datetime', @date_filter; @@ -4634,7 +4634,7 @@ BEGIN IF @debug = 1 BEGIN RAISERROR(@the_deleter_must_awaken, 0, 1) WITH NOWAIT; END; /* execute the delete */ - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @the_deleter_must_awaken, N'@delete_retention_days INT', @delete_retention_days; @@ -4667,7 +4667,7 @@ BEGIN ON dxs.name = ses.name WHERE ses.name LIKE N'%HumanEvents_%'; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @cleanup_sessions; IF @debug = 1 BEGIN RAISERROR(@cleanup_sessions, 0, 1) WITH NOWAIT; END; @@ -4689,7 +4689,7 @@ BEGIN FROM ' + QUOTENAME(@output_database_name) + N'.sys.tables AS s WHERE s.name LIKE ''' + '%HumanEvents%' + N''';'; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @cleanup_tables, N'@i_cleanup_tables nvarchar(MAX) OUTPUT', @i_cleanup_tables = @drop_holder OUTPUT; @@ -4700,7 +4700,7 @@ BEGIN RAISERROR(@drop_holder, 0, 1) WITH NOWAIT; END; - EXEC @executer @drop_holder; + EXECUTE @executer @drop_holder; /*Cleanup views*/ RAISERROR(N'CLEAN UP PARTY TONIGHT', 0, 1) WITH NOWAIT; @@ -4720,7 +4720,7 @@ BEGIN FROM ' + QUOTENAME(@output_database_name) + N'.sys.views AS v WHERE v.name LIKE ''' + '%HumanEvents%' + N''';'; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @cleanup_views, N'@i_cleanup_views nvarchar(MAX) OUTPUT', @i_cleanup_views = @drop_holder OUTPUT; @@ -4731,7 +4731,7 @@ BEGIN RAISERROR(@drop_holder, 0, 1) WITH NOWAIT; END; - EXEC @executer @drop_holder; + EXECUTE @executer @drop_holder; RETURN; END; @@ -4749,11 +4749,11 @@ BEGIN CATCH BEGIN IF @debug = 1 BEGIN RAISERROR(@stop_sql, 0, 1) WITH NOWAIT; END; RAISERROR(N'all done, stopping session', 0, 1) WITH NOWAIT; - EXEC (@stop_sql); + EXECUTE (@stop_sql); IF @debug = 1 BEGIN RAISERROR(@drop_sql, 0, 1) WITH NOWAIT; END; RAISERROR(N'and dropping session', 0, 1) WITH NOWAIT; - EXEC (@drop_sql); + EXECUTE (@drop_sql); END; THROW; diff --git a/sp_HumanEvents/sp_HumanEventsBlockViewer.sql b/sp_HumanEvents/sp_HumanEventsBlockViewer.sql index 67fc6d6..5fc764d 100644 --- a/sp_HumanEvents/sp_HumanEventsBlockViewer.sql +++ b/sp_HumanEvents/sp_HumanEventsBlockViewer.sql @@ -42,11 +42,11 @@ Copyright 2025 Darling Data, LLC https://www.erikdarling.com/ For usage and licensing details, run: -EXEC sp_HumanEventsBlockViewer +EXECUTE sp_HumanEventsBlockViewer @help = 1; For working through errors: -EXEC sp_HumanEventsBlockViewer +EXECUTE sp_HumanEventsBlockViewer @debug = 1; For support, head over to GitHub: @@ -55,7 +55,7 @@ https://github.com/erikdarlingdata/DarlingData IF OBJECT_ID('dbo.sp_HumanEventsBlockViewer') IS NULL BEGIN - EXEC ('CREATE PROCEDURE dbo.sp_HumanEventsBlockViewer AS RETURN 138;'); + EXECUTE ('CREATE PROCEDURE dbo.sp_HumanEventsBlockViewer AS RETURN 138;'); END; GO @@ -91,10 +91,10 @@ BEGIN introduction = 'hi, i''m sp_HumanEventsBlockViewer!' UNION ALL SELECT 'you can use me in conjunction with sp_HumanEvents to quickly parse the sqlserver.blocked_process_report event' UNION ALL - SELECT 'EXEC sp_HumanEvents @event_type = N''blocking'', @keep_alive = 1;' UNION ALL + SELECT 'EXECUTE sp_HumanEvents @event_type = N''blocking'', @keep_alive = 1;' UNION ALL SELECT 'it will also work with any other extended event session that captures blocking' UNION ALL SELECT 'just use the @session_name parameter to point me there' UNION ALL - SELECT 'EXEC dbo.sp_HumanEventsBlockViewer @session_name = N''blocked_process_report'';' UNION ALL + SELECT 'EXECUTE dbo.sp_HumanEventsBlockViewer @session_name = N''blocked_process_report'';' UNION ALL SELECT 'all scripts and documentation are available here: https://github.com/erikdarlingdata/DarlingData/tree/main/sp_HumanEvents' UNION ALL SELECT 'from your loving sql server consultant, erik darling: https://erikdarling.com'; @@ -156,8 +156,8 @@ BEGIN RAISERROR(' The blocked process report needs to be enabled: -EXEC sys.sp_configure ''show advanced options'', 1; -EXEC sys.sp_configure ''blocked process threshold'', 5; /* Seconds of blocking before a report is generated */ +EXECUTE sys.sp_configure ''show advanced options'', 1; +EXECUTE sys.sp_configure ''blocked process threshold'', 5; /* Seconds of blocking before a report is generated */ RECONFIGURE;', 0, 1) WITH NOWAIT; RAISERROR(' @@ -235,8 +235,8 @@ IF EXISTS ) BEGIN RAISERROR(N'The blocked process report needs to be enabled: -EXEC sys.sp_configure ''show advanced options'', 1; -EXEC sys.sp_configure ''blocked process threshold'', 5; /* Seconds of blocking before a report is generated */ +EXECUTE sys.sp_configure ''show advanced options'', 1; +EXECUTE sys.sp_configure ''blocked process threshold'', 5; /* Seconds of blocking before a report is generated */ RECONFIGURE;', 11, 0) WITH NOWAIT; RETURN; @@ -253,8 +253,8 @@ IF EXISTS ) BEGIN RAISERROR(N'For best results, set up the blocked process report like this: -EXEC sys.sp_configure ''show advanced options'', 1; -EXEC sys.sp_configure ''blocked process threshold'', 5; /* Seconds of blocking before a report is generated */ +EXECUTE sys.sp_configure ''show advanced options'', 1; +EXECUTE sys.sp_configure ''blocked process threshold'', 5; /* Seconds of blocking before a report is generated */ RECONFIGURE;', 10, 0) WITH NOWAIT; END; @@ -1817,7 +1817,7 @@ SELECT b.host_name, b.login_name, b.transaction_id, - b.blocked_process_report + blocked_process_report_xml = b.blocked_process_report FROM ( SELECT diff --git a/sp_LogHunter/sp_LogHunter.sql b/sp_LogHunter/sp_LogHunter.sql index 4bd2ab8..fb1d839 100644 --- a/sp_LogHunter/sp_LogHunter.sql +++ b/sp_LogHunter/sp_LogHunter.sql @@ -28,23 +28,23 @@ Copyright 2025 Darling Data, LLC https://www.erikdarling.com/ For usage and licensing details, run: -EXEC sp_LogHunter +EXECUTE sp_LogHunter @help = 1; For working through errors: -EXEC sp_LogHunter +EXECUTE sp_LogHunter @debug = 1; For support, head over to GitHub: https://github.com/erikdarlingdata/DarlingData -EXEC sp_LogHunter; +EXECUTE sp_LogHunter; */ IF OBJECT_ID('dbo.sp_LogHunter') IS NULL BEGIN - EXEC ('CREATE PROCEDURE dbo.sp_LogHunter AS RETURN 138;'); + EXECUTE ('CREATE PROCEDURE dbo.sp_LogHunter AS RETURN 138;'); END; GO @@ -314,7 +314,7 @@ BEGIN CONVERT ( nvarchar(4000), - N'EXEC master.dbo.xp_readerrorlog [@@@], 1, ' + N'EXECUTE master.dbo.xp_readerrorlog [@@@], 1, ' + search_string + N', ' + N'" "' @@ -343,7 +343,7 @@ BEGIN log_date, log_size ) - EXEC sys.sp_enumerrorlogs; + EXECUTE sys.sp_enumerrorlogs; IF @debug = 1 BEGIN SELECT table_name = '#enum before delete', e.* FROM #enum AS e; END; @@ -575,7 +575,7 @@ BEGIN process_info, text ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @c; END TRY BEGIN CATCH diff --git a/sp_PressureDetector/sp_PressureDetector.sql b/sp_PressureDetector/sp_PressureDetector.sql index bcdec13..b87bb9b 100644 --- a/sp_PressureDetector/sp_PressureDetector.sql +++ b/sp_PressureDetector/sp_PressureDetector.sql @@ -29,11 +29,11 @@ Copyright 2025 Darling Data, LLC https://www.erikdarling.com/ For usage and licensing details, run: -EXEC sp_PressureDetector +EXECUTE sp_PressureDetector @help = 1; For working through errors: -EXEC sp_PressureDetector +EXECUTE sp_PressureDetector @debug = 1; For support, head over to GitHub: @@ -43,7 +43,7 @@ https://github.com/erikdarlingdata/DarlingData IF OBJECT_ID('dbo.sp_PressureDetector') IS NULL - EXEC ('CREATE PROCEDURE dbo.sp_PressureDetector AS RETURN 138;'); + EXECUTE ('CREATE PROCEDURE dbo.sp_PressureDetector AS RETURN 138;'); GO ALTER PROCEDURE @@ -464,7 +464,7 @@ OPTION(MAXDOP 1, RECOMPILE);', message = 'This works a lot better on a troublesome server with the DAC enabled', command_to_run = - 'EXEC sp_configure ''remote admin connections'', 1; RECONFIGURE;', + 'EXECUTE sp_configure ''remote admin connections'', 1; RECONFIGURE;', how_to_use_the_dac = 'https://bit.ly/RemoteDAC'; END; @@ -1056,7 +1056,7 @@ OPTION(MAXDOP 1, RECOMPILE);', io_stall_write_ms, sample_time ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @disk_check; IF @sample_seconds = 0 @@ -1777,7 +1777,7 @@ OPTION(MAXDOP 1, RECOMPILE);', PRINT @pool_sql; END; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @pool_sql; /*Checking total database size*/ @@ -1817,7 +1817,7 @@ OPTION(MAXDOP 1, RECOMPILE);', OPTION(MAXDOP 1, RECOMPILE);'; END; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @database_size_out, N'@database_size_out_gb varchar(10) OUTPUT', @database_size_out_gb OUTPUT; @@ -2042,7 +2042,7 @@ OPTION(MAXDOP 1, RECOMPILE);', RAISERROR('%s', 0, 1, @cache_sql) WITH NOWAIT; END; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @cache_sql, N'@cache_xml xml OUTPUT', @cache_xml OUTPUT; @@ -2411,7 +2411,7 @@ OPTION(MAXDOP 1, RECOMPILE);', PRINT SUBSTRING(@mem_sql, 4000, 8000); END; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @mem_sql; END; @@ -2436,7 +2436,7 @@ OPTION(MAXDOP 1, RECOMPILE);', PRINT @reserved_worker_count; END; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @reserved_worker_count, N'@reserved_worker_count_out varchar(10) OUTPUT', @reserved_worker_count_out OUTPUT; @@ -2499,7 +2499,7 @@ OPTION(MAXDOP 1, RECOMPILE);', PRINT @cpu_details; END; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @cpu_details, N'@cpu_details_output xml OUTPUT', @cpu_details_output OUTPUT; @@ -2969,7 +2969,7 @@ OPTION(MAXDOP 1, RECOMPILE);', PRINT SUBSTRING(@cpu_sql, 4000, 8000); END; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @cpu_sql; END; /*End not skipping queries*/ END; /*End CPU checks*/ diff --git a/sp_QuickieStore/Examples.sql b/sp_QuickieStore/Examples.sql index 3143d36..0e39a6e 100644 --- a/sp_QuickieStore/Examples.sql +++ b/sp_QuickieStore/Examples.sql @@ -13,7 +13,7 @@ β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘ β•šβ•β•β•β•β•β•β•šβ•β• β•šβ•β•β•šβ•β•β•β•β•β•β•β•šβ•β•β•β•β•β•β•β•šβ•β•β•β•β•β•β• -Copyright 2024 Darling Data, LLC +Copyright 2025 Darling Data, LLC https://www.erikdarling.com/ For support, head over to GitHub: @@ -21,34 +21,34 @@ https://github.com/erikdarlingdata/DarlingData */ /*Get help!*/ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @help = 1; /*The default is finding the top 10 sorted by CPU in the last seven days.*/ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @database_name = 'StackOverflow2013'; /*Find top 10 sorted by memory*/ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @database_name = 'StackOverflow2013', @sort_order = 'memory', @top = 10; /*Find top 10 in each user database sorted by cpu*/ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @get_all_databases = 1, @sort_order = 'cpu', @top = 10; /*Search for specific query_ids*/ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @database_name = 'StackOverflow2013', @top = 10, @include_query_ids = '13977, 13978'; /*Search for specific plan_ids*/ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @database_name = 'StackOverflow2013', @sort_order = 'memory', @top = 10, @@ -57,14 +57,14 @@ EXEC dbo.sp_QuickieStore /*Ignore for specific query_ids*/ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @database_name = 'StackOverflow2013', @top = 10, @ignore_query_ids = '13977, 13978'; /*Ignore for specific plan_ids*/ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @database_name = 'StackOverflow2013', @sort_order = 'memory', @top = 10, @@ -73,7 +73,7 @@ EXEC dbo.sp_QuickieStore /*Search for queries within a date range*/ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @database_name = 'StackOverflow2013', @sort_order = 'memory', @top = 10, @@ -81,7 +81,7 @@ EXEC dbo.sp_QuickieStore @end_date = '20210321'; /*Filter out weekends and anything outside of your choice of hours.*/ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @database_name = 'StackOverflow2013', @workdays = 1, @work_start = '8am', @@ -89,21 +89,21 @@ EXEC dbo.sp_QuickieStore /*Search for queries with a minimum execution count*/ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @database_name = 'StackOverflow2013', @top = 10, @execution_count = 10; /*Search for queries over a specific duration*/ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @database_name = 'StackOverflow2013', @top = 10, @duration_ms = 10000; /*Use wait filter to search for queries responsible for high waits*/ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @database_name = 'StackOverflow2013', @wait_filter = 'memory', @sort_order = 'memory'; @@ -112,12 +112,12 @@ EXEC dbo.sp_QuickieStore The wait-related sort orders are special because we add an extra column for the duration of the wait type you are asking for. It's all the way over on the right. */ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @database_name = 'StackOverflow2013', @sort_order = 'memory waits'; /*You can also sort by total wait time across all waits. */ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @database_name = 'StackOverflow2013', @sort_order = 'total waits'; @@ -127,7 +127,7 @@ When we do not provide this parameter, we grab all types. This example grabs "aborted" queries, which are queries cancelled by the client. This is a great way to find timeouts. */ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @database_name = 'StackOverflow2013', @top = 10, @execution_type_desc = 'aborted'; @@ -137,7 +137,7 @@ As above, but for "exception" queries. This grabs queries that were cancelled by throwing exceptions. It's no substitute for proper error monitoring, but it can be a good early warning. */ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @database_name = 'StackOverflow2013', @top = 10, @execution_type_desc = 'exception'; @@ -146,32 +146,32 @@ EXEC dbo.sp_QuickieStore As above, but for "regular" queries. This grabs queries that were not cancelled. */ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @database_name = 'StackOverflow2013', @top = 10, @execution_type_desc = 'regular'; /*Search for a specific stored procedure*/ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @database_name = 'StackOverflow2013', @procedure_name = 'top_percent_sniffer'; /*Search for a specific stored procedure in a specific schema*/ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @database_name = 'StackOverflow2013', @procedure_schema = 'not_dbo' @procedure_name = 'top_percent_sniffer'; /*Search for specific query text*/ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @database_name = 'StackOverflow2013', @query_text_search = 'WITH Comment'; /*Search for specific query text, with brackets automatically escaped. Commonly needed when dealing with ORM queries. */ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @database_name = 'StackOverflow2013', @query_text_search = 'FROM [users] AS [t0]', @escape_brackets = 1; @@ -180,7 +180,7 @@ EXEC dbo.sp_QuickieStore Maybe you want something else. Provide it with @escape_character. */ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @database_name = 'StackOverflow2013', @query_text_search = 'FROM foo\bar AS [t0]', @escape_character = '~' @@ -194,7 +194,7 @@ Makes use of @get_all_databases = 1, which lets you search all user databases. Note the abuse of @start_date. By setting it very far back in the past and leaving @end_date unspecified, we cover all of the data. We also abuse @top by setting it very high. */ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @get_all_databases = 1, @start_date = '20000101', @sort_order = 'executions', @@ -205,7 +205,7 @@ EXEC dbo.sp_QuickieStore Good for when @query_text_search gets false positives. After all, it's only doing string searching. */ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @get_all_databases = 1, @start_date = '20000101', @sort_order = 'executions', @@ -215,7 +215,7 @@ EXEC dbo.sp_QuickieStore /*What happened recently on a database?*/ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @database_name = 'StackOverflow2013' @sort_order = 'recent'; @@ -223,7 +223,7 @@ EXEC dbo.sp_QuickieStore Good for finding cross-database queries, such as when checking if a database is dead code. Don't forget that queries in a database do not need to reference it explicitly! */ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @get_all_databases = 1, @start_date = '20000101', @sort_order = 'recent', @@ -231,32 +231,32 @@ EXEC dbo.sp_QuickieStore @top = 10; /*Only return queries with feedback (2022+)*/ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @database_name = 'StackOverflow2013', @only_query_with_feedback = 1; /*Only return queries with variants (2022+)*/ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @database_name = 'StackOverflow2013', @only_query_with_variants = 1; /*Only return queries with forced plans (2022+)*/ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @database_name = 'StackOverflow2013', @only_query_with_forced_plans = 1; /*Only return queries with forced plan failures (2022+)*/ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @database_name = 'StackOverflow2013', @only_query_with_forced_plan_failures = 1; /*Only return queries with query hints (2022+)*/ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @database_name = 'StackOverflow2013', @only_query_with_hints = 1; /*Use expert mode to return additional columns*/ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @database_name = 'StackOverflow2013', @sort_order = 'memory', @top = 10, @@ -266,14 +266,14 @@ EXEC dbo.sp_QuickieStore /*Use format output to add commas to larger numbers This is enabled by default. */ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @database_name = 'StackOverflow2013', @sort_order = 'memory', @top = 10, @format_output = 1; /*Disable format output to remove commas.*/ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @database_name = 'StackOverflow2013', @sort_order = 'memory', @top = 10, @@ -283,45 +283,45 @@ EXEC dbo.sp_QuickieStore This is only an output-formatting change. It does not change how dates are processed. */ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @database_name = 'StackOverflow2013', @timezone = 'Egypt Standard Time'; /*Debugging something complex? Hide the bottom table with @hide_help_table = 1 when you need more room. */ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @database_name = 'StackOverflow2013', @hide_help_table = 1, @sort_order = 'latch waits', @top = 50; /*Search by query hashes*/ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @include_query_hashes = '0x1AB614B461F4D769,0x1CD777B461F4D769'; /*Search by plan hashes*/ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @include_plan_hashes = '0x6B84B820B8B38564,0x6B84B999D7B38564'; /*Search by SQL Handles Do you need to find if one Query Store is tracking the same query that is present in another database's Query Store? If so, use the statement_sql_handle to do that. This helps with scenarios where you have multiple production databases which have the same schema and you want to compare performance across Query Stores. */ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @include_sql_handles = '0x0900F46AC89E66DF744C8A0AD4FD3D3306B90000000000000000000000000000000000000000000000000000,0x0200000AC89E66DF744C8A0AD4FD3D3306B90000000000000000000000000000000000000000000000000000'; /*Search, but ignoring some query hashes*/ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @ignore_query_hashes = '0x1AB614B461F4D769,0x1CD777B461F4D769'; /*Search, but ignoring some plan hashes*/ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @ignore_plan_hashes = '0x6B84B820B8B38564,0x6B84B999D7B38564'; /*Search, but ignoring some SQL Handles*/ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @ignore_sql_handles = '0x0900F46AC89E66DF744C8A0AD4FD3D3306B90000000000000000000000000000000000000000000000000000,0x0200000AC89E66DF744C8A0AD4FD3D3306B90000000000000000000000000000000000000000000000000000'; @@ -329,7 +329,7 @@ EXEC dbo.sp_QuickieStore This sort order is special because it needs to return multiple rows for each of the @top hashes it looks at. It is also special because it adds some new columns all the way over on the right of the output. */ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @database_name = 'StackOverflow2013', @sort_order = 'plan count by hashes'; @@ -341,7 +341,7 @@ Searches by query hash, so you will won't be caught out by identical queries wit */ DECLARE @TwoWeekAgo datetimeoffset(7) = DATEADD(WEEK, -2, SYSDATETIMEOFFSET()); -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @database_name = 'StackOverflow2013', @sort_order = 'logical reads', @regression_baseline_start_date = @TwoWeekAgo; @@ -357,7 +357,7 @@ DECLARE @StartOfYesterday datetimeoffset(7) = CONVERT(date, DATEADD(DAY, -1, SYS @StartOfToday datetimeoffset(7) = CONVERT(date, SYSDATETIMEOFFSET()), @StartOfTomorrow datetimeoffset(7) = CONVERT(date, DATEADD(DAY, 1, SYSDATETIMEOFFSET())); -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @database_name = 'StackOverflow2013', @sort_order = 'writes', @regression_direction = 'improved', @@ -378,14 +378,14 @@ To save space on your screen, we will specify @hide_help_table = 1 to hide the t */ DECLARE @TwoWeekAgo datetimeoffset(7) = DATEADD(WEEK, -2, SYSDATETIMEOFFSET()); -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @database_name = 'StackOverflow2013', @sort_order = 'physical reads', @hide_help_table = 1, @regression_comparator = 'relative', @regression_baseline_start_date = @TwoWeekAgo; -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @database_name = 'StackOverflow2013', @sort_order = 'physical reads', @hide_help_table = 1, @@ -400,7 +400,7 @@ And while we're at it, let's check all user databases with @get_all_databases = */ DECLARE @TwoWeekAgo datetimeoffset(7) = DATEADD(WEEK, -2, SYSDATETIMEOFFSET()); -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @get_all_databases = 1, @sort_order = 'duration', @regression_direction = 'absolute', @@ -410,7 +410,7 @@ EXEC dbo.sp_QuickieStore DECLARE @version_output varchar(30), @version_date_output datetime; -EXEC sp_QuickieStore +EXECUTE sp_QuickieStore @version = @version_output OUTPUT, @version_date = @version_date_output OUTPUT; @@ -419,7 +419,7 @@ SELECT VersionDate = @version_date_output; /*Search for queries that take a while and return lots of rows on average*/ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @database_name = 'StackOverflow2013', @top = 10, @sort_order = 'rows', @@ -427,11 +427,11 @@ EXEC dbo.sp_QuickieStore /*Troubleshoot performance*/ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @database_name = 'StackOverflow2013', @troubleshoot_performance = 1; /*Debug dynamic SQL and temp table contents*/ -EXEC dbo.sp_QuickieStore +EXECUTE dbo.sp_QuickieStore @database_name = 'StackOverflow2013', @debug = 1; diff --git a/sp_QuickieStore/sp_QuickieStore.sql b/sp_QuickieStore/sp_QuickieStore.sql index 97bf118..974e783 100644 --- a/sp_QuickieStore/sp_QuickieStore.sql +++ b/sp_QuickieStore/sp_QuickieStore.sql @@ -29,15 +29,15 @@ Copyright 2025 Darling Data, LLC https://www.erikdarling.com/ For usage and licensing details, run: -EXEC sp_QuickieStore +EXECUTE sp_QuickieStore @help = 1; For working through errors: -EXEC sp_QuickieStore +EXECUTE sp_QuickieStore @debug = 1; For performance issues: -EXEC sp_QuickieStore +EXECUTE sp_QuickieStore @troubleshoot_performance = 1; For support, head over to GitHub: @@ -47,7 +47,7 @@ https://github.com/erikdarlingdata/DarlingData IF OBJECT_ID('dbo.sp_QuickieStore') IS NULL BEGIN - EXEC ('CREATE PROCEDURE dbo.sp_QuickieStore AS RETURN 138;'); + EXECUTE ('CREATE PROCEDURE dbo.sp_QuickieStore AS RETURN 138;'); END; GO @@ -2170,7 +2170,7 @@ SELECT IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -2211,7 +2211,7 @@ BEGIN PRINT @sql; END; -EXEC sys.sp_executesql +EXECUTE sys.sp_executesql @sql, N'@query_store_exists bit OUTPUT', @query_store_exists OUTPUT; @@ -2220,12 +2220,12 @@ IF @troubleshoot_performance = 1 BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -2260,7 +2260,7 @@ SELECT IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -2336,7 +2336,7 @@ INSERT query_capture_mode_desc, size_based_cleanup_mode_desc ) -EXEC sys.sp_executesql +EXECUTE sys.sp_executesql @sql, N'@database_id integer', @database_id; @@ -2351,12 +2351,12 @@ IF @troubleshoot_performance = 1 BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -2382,7 +2382,7 @@ BEGIN IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -2416,7 +2416,7 @@ AND p.name LIKE @procedure_name;' + @nc10; ( [object_id] ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql, N'@procedure_schema sysname, @procedure_name sysname', @@ -2427,12 +2427,12 @@ AND p.name LIKE @procedure_name;' + @nc10; BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -2446,7 +2446,7 @@ AND p.name LIKE @procedure_name;' + @nc10; IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -2489,7 +2489,7 @@ OPTION(RECOMPILE);' + @nc10; PRINT @sql; END; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql, N'@procedure_exists bit OUTPUT, @procedure_name_quoted sysname', @@ -2500,12 +2500,12 @@ OPTION(RECOMPILE);' + @nc10; BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -2522,7 +2522,7 @@ OPTION(RECOMPILE);' + @nc10; IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -2553,7 +2553,7 @@ OPTION(RECOMPILE);' + @nc10; PRINT @sql; END; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql, N'@procedure_exists bit OUTPUT, @procedure_name_quoted sysname', @@ -2564,12 +2564,12 @@ OPTION(RECOMPILE);' + @nc10; BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -2853,7 +2853,7 @@ BEGIN IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -2884,7 +2884,7 @@ OPTION(RECOMPILE);' + @nc10; PRINT @sql; END; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql, N'@query_store_waits_enabled bit OUTPUT', @query_store_waits_enabled OUTPUT; @@ -2893,12 +2893,12 @@ OPTION(RECOMPILE);' + @nc10; BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -3114,7 +3114,7 @@ BEGIN IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -3164,7 +3164,7 @@ OPTION(RECOMPILE);' + @nc10; ( plan_id ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql, N'@procedure_name_quoted sysname', @procedure_name_quoted; @@ -3173,12 +3173,12 @@ OPTION(RECOMPILE);' + @nc10; BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -3209,7 +3209,7 @@ BEGIN IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -3244,19 +3244,19 @@ OPTION(RECOMPILE);' + @nc10; ( plan_id ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql; IF @troubleshoot_performance = 1 BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -3303,7 +3303,7 @@ BEGIN ( plan_id ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @string_split_ints, N'@ids nvarchar(4000)', @include_plan_ids; @@ -3335,7 +3335,7 @@ BEGIN ( plan_id ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @string_split_ints, N'@ids nvarchar(4000)', @ignore_plan_ids; @@ -3367,7 +3367,7 @@ BEGIN ( query_id ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @string_split_ints, N'@ids nvarchar(4000)', @include_query_ids; @@ -3377,7 +3377,7 @@ BEGIN IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -3410,19 +3410,19 @@ OPTION(RECOMPILE);' + @nc10; ( plan_id ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql; IF @troubleshoot_performance = 1 BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -3470,7 +3470,7 @@ OPTION(RECOMPILE);' + @nc10; ( query_id ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @string_split_ints, N'@ids nvarchar(4000)', @ignore_query_ids; @@ -3480,7 +3480,7 @@ OPTION(RECOMPILE);' + @nc10; IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -3513,19 +3513,19 @@ OPTION(RECOMPILE);' + @nc10; ( plan_id ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql; IF @troubleshoot_performance = 1 BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -3588,7 +3588,7 @@ BEGIN ( query_hash_s ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @string_split_strings, N'@ids nvarchar(4000)', @include_query_hashes; @@ -3598,7 +3598,7 @@ BEGIN IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -3638,19 +3638,19 @@ OPTION(RECOMPILE);' + @nc10; ( plan_id ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql; IF @troubleshoot_performance = 1 BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -3699,7 +3699,7 @@ OPTION(RECOMPILE);' + @nc10; ( query_hash_s ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @string_split_strings, N'@ids nvarchar(4000)', @ignore_query_hashes; @@ -3709,7 +3709,7 @@ OPTION(RECOMPILE);' + @nc10; IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -3749,19 +3749,19 @@ OPTION(RECOMPILE);' + @nc10; ( plan_id ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql; IF @troubleshoot_performance = 1 BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -3810,7 +3810,7 @@ OPTION(RECOMPILE);' + @nc10; ( plan_hash_s ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @string_split_strings, N'@ids nvarchar(4000)', @include_plan_hashes; @@ -3820,7 +3820,7 @@ OPTION(RECOMPILE);' + @nc10; IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -3853,19 +3853,19 @@ OPTION(RECOMPILE);' + @nc10; ( plan_id ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql; IF @troubleshoot_performance = 1 BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -3914,7 +3914,7 @@ OPTION(RECOMPILE);' + @nc10; ( plan_hash_s ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @string_split_strings, N'@ids nvarchar(4000)', @ignore_plan_hashes; @@ -3924,7 +3924,7 @@ OPTION(RECOMPILE);' + @nc10; IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -3957,19 +3957,19 @@ OPTION(RECOMPILE);' + @nc10; ( plan_id ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql; IF @troubleshoot_performance = 1 BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -4018,7 +4018,7 @@ OPTION(RECOMPILE);' + @nc10; ( sql_handle_s ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @string_split_strings, N'@ids nvarchar(4000)', @include_sql_handles; @@ -4029,7 +4029,7 @@ OPTION(RECOMPILE);' + @nc10; IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -4076,19 +4076,19 @@ OPTION(RECOMPILE);' + @nc10; ( plan_id ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql; IF @troubleshoot_performance = 1 BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -4137,7 +4137,7 @@ OPTION(RECOMPILE);' + @nc10; ( sql_handle_s ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @string_split_strings, N'@ids nvarchar(4000)', @ignore_sql_handles; @@ -4147,7 +4147,7 @@ OPTION(RECOMPILE);' + @nc10; IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -4194,19 +4194,19 @@ OPTION(RECOMPILE);' + @nc10; ( plan_id ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql; IF @troubleshoot_performance = 1 BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -4248,7 +4248,7 @@ BEGIN IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -4284,19 +4284,19 @@ BEGIN ( plan_id ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql IF @troubleshoot_performance = 1 BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -4322,7 +4322,7 @@ BEGIN IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -4358,19 +4358,19 @@ BEGIN ( plan_id ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql IF @troubleshoot_performance = 1 BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -4396,7 +4396,7 @@ BEGIN IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -4432,19 +4432,19 @@ BEGIN ( plan_id ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql IF @troubleshoot_performance = 1 BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -4475,7 +4475,7 @@ BEGIN IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -4512,19 +4512,19 @@ OPTION(RECOMPILE);' + @nc10; ( plan_id ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql IF @troubleshoot_performance = 1 BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -4593,7 +4593,7 @@ BEGIN IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -4668,7 +4668,7 @@ END; ( plan_id ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql, N'@query_text_search nvarchar(4000)', @query_text_search; @@ -4677,12 +4677,12 @@ END; BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -4751,7 +4751,7 @@ BEGIN IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -4826,7 +4826,7 @@ END; ( plan_id ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql, N'@query_text_search_not nvarchar(4000)', @query_text_search_not; @@ -4835,12 +4835,12 @@ END; BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -4870,7 +4870,7 @@ BEGIN IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -4923,7 +4923,7 @@ OPTION(RECOMPILE, OPTIMIZE FOR (@top = 9223372036854775807));' + @nc10; ( plan_id ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql, N'@top bigint', @top; @@ -4932,12 +4932,12 @@ OPTION(RECOMPILE, OPTIMIZE FOR (@top = 9223372036854775807));' + @nc10; BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -4965,7 +4965,7 @@ SELECT IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -5008,19 +5008,19 @@ INSERT ( plan_id ) -EXEC sys.sp_executesql +EXECUTE sys.sp_executesql @sql; IF @troubleshoot_performance = 1 BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -5126,7 +5126,7 @@ BEGIN IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -5209,7 +5209,7 @@ BEGIN query_hash, plan_hash_count_for_query_hash ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql, @parameters, @top, @@ -5229,12 +5229,12 @@ BEGIN BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -5250,7 +5250,7 @@ BEGIN IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -5326,7 +5326,7 @@ OR from_regression_baseline, total_query_wait_time_ms ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql, @parameters, @top, @@ -5346,12 +5346,12 @@ OR BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -5373,7 +5373,7 @@ BEGIN IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -5468,7 +5468,7 @@ BEGIN from_regression_baseline, total_query_wait_time_ms ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql, @parameters, @top, @@ -5488,12 +5488,12 @@ BEGIN BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -5521,7 +5521,7 @@ BEGIN IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -5576,7 +5576,7 @@ BEGIN query_hash, regression_metric_average ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql, @parameters, @top, @@ -5596,12 +5596,12 @@ BEGIN BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -5619,7 +5619,7 @@ BEGIN IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -5675,7 +5675,7 @@ BEGIN query_hash, current_metric_average ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql, @parameters, @top, @@ -5695,12 +5695,12 @@ BEGIN BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -5714,7 +5714,7 @@ BEGIN IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -5861,7 +5861,7 @@ BEGIN query_hash, change_since_regression_time_period ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql, @parameters, @top, @@ -5881,12 +5881,12 @@ BEGIN BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -5910,7 +5910,7 @@ SELECT IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -5990,7 +5990,7 @@ INSERT ( plan_id ) -EXEC sys.sp_executesql +EXECUTE sys.sp_executesql @sql, @parameters, @top, @@ -6010,12 +6010,12 @@ IF @troubleshoot_performance = 1 BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -6033,7 +6033,7 @@ SELECT IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -6458,7 +6458,7 @@ INSERT from_regression_baseline, context_settings ) -EXEC sys.sp_executesql +EXECUTE sys.sp_executesql @sql, @parameters, @top, @@ -6478,12 +6478,12 @@ IF @troubleshoot_performance = 1 BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -6500,7 +6500,7 @@ SELECT IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -6645,7 +6645,7 @@ INSERT is_optimized_plan_forcing_disabled, plan_type_desc ) -EXEC sys.sp_executesql +EXECUTE sys.sp_executesql @sql, N'@plans_top bigint, @database_id int', @@ -6656,12 +6656,12 @@ IF @troubleshoot_performance = 1 BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -6678,7 +6678,7 @@ SELECT IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -6772,7 +6772,7 @@ INSERT max_compile_memory_mb, is_clouddb_internal_query ) -EXEC sys.sp_executesql +EXECUTE sys.sp_executesql @sql, N'@database_id int', @database_id; @@ -6781,12 +6781,12 @@ IF @troubleshoot_performance = 1 BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -6803,7 +6803,7 @@ SELECT IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -6862,7 +6862,7 @@ INSERT is_part_of_encrypted_module, has_restricted_text ) -EXEC sys.sp_executesql +EXECUTE sys.sp_executesql @sql, N'@database_id int', @database_id; @@ -6871,12 +6871,12 @@ IF @troubleshoot_performance = 1 BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -6894,7 +6894,7 @@ SELECT IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -7033,12 +7033,12 @@ IF @troubleshoot_performance = 1 BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -7054,7 +7054,7 @@ BEGIN IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -7094,12 +7094,12 @@ BEGIN BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -7118,7 +7118,7 @@ SELECT IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -7226,7 +7226,7 @@ INSERT size_based_cleanup_mode_desc, wait_stats_capture_mode_desc ) -EXEC sys.sp_executesql +EXECUTE sys.sp_executesql @sql, N'@database_id int', @database_id; @@ -7235,12 +7235,12 @@ IF @troubleshoot_performance = 1 BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -7269,7 +7269,7 @@ BEGIN IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -7354,7 +7354,7 @@ OPTION(RECOMPILE);' + @nc10; min_query_wait_time_ms, max_query_wait_time_ms ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql, N'@database_id int', @database_id; @@ -7363,12 +7363,12 @@ OPTION(RECOMPILE);' + @nc10; BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -7386,7 +7386,7 @@ SELECT IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -7443,7 +7443,7 @@ INSERT is_replication_specific, is_contained ) -EXEC sys.sp_executesql +EXECUTE sys.sp_executesql @sql, N'@database_id int', @database_id; @@ -7452,12 +7452,12 @@ IF @troubleshoot_performance = 1 BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -7571,7 +7571,7 @@ BEGIN IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -7618,7 +7618,7 @@ OPTION(RECOMPILE);' + @nc10; create_time, last_updated_time ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql, N'@database_id int', @database_id; @@ -7627,12 +7627,12 @@ OPTION(RECOMPILE);' + @nc10; BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -7647,7 +7647,7 @@ OPTION(RECOMPILE);' + @nc10; IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -7687,7 +7687,7 @@ OPTION(RECOMPILE);' + @nc10; parent_query_id, dispatcher_plan_id ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql, N'@database_id int', @database_id; @@ -7696,12 +7696,12 @@ OPTION(RECOMPILE);' + @nc10; BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -7716,7 +7716,7 @@ OPTION(RECOMPILE);' + @nc10; IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -7761,7 +7761,7 @@ OPTION(RECOMPILE);' + @nc10; query_hint_failure_count, source_desc ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql, N'@database_id int', @database_id; @@ -7770,12 +7770,12 @@ OPTION(RECOMPILE);' + @nc10; BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -7792,7 +7792,7 @@ OPTION(RECOMPILE);' + @nc10; IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -7834,7 +7834,7 @@ OPTION(RECOMPILE);' + @nc10; plan_id, replica_group_id ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql, N'@database_id int', @database_id; @@ -7843,12 +7843,12 @@ OPTION(RECOMPILE);' + @nc10; BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -7863,7 +7863,7 @@ OPTION(RECOMPILE);' + @nc10; IF @troubleshoot_performance = 1 BEGIN - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_insert, N'@current_table nvarchar(100)', @current_table; @@ -7902,7 +7902,7 @@ OPTION(RECOMPILE);' + @nc10; role_type, replica_name ) - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql, N'@database_id int', @database_id; @@ -7911,12 +7911,12 @@ OPTION(RECOMPILE);' + @nc10; BEGIN SET STATISTICS XML OFF; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_update, N'@current_table nvarchar(100)', @current_table; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @troubleshoot_info, N'@sql nvarchar(max), @current_table nvarchar(100)', @@ -9396,7 +9396,7 @@ OPTION(RECOMPILE);' PRINT SUBSTRING(@sql, 8000, 16000); END; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql, N'@utc_offset_string nvarchar(6), @timezone sysname', @@ -9991,7 +9991,7 @@ BEGIN PRINT @sql; END; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql; END; END; /*End expert mode format output = 0*/ @@ -10620,7 +10620,7 @@ BEGIN PRINT @sql; END; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql; END; @@ -10761,11 +10761,11 @@ BEGIN support = 'https://github.com/erikdarlingdata/DarlingData', help = - 'EXEC sp_QuickieStore @help = 1;', + 'EXECUTE sp_QuickieStore @help = 1;', problems = - 'EXEC sp_QuickieStore @debug = 1;', + 'EXECUTE sp_QuickieStore @debug = 1;', performance = - 'EXEC sp_QuickieStore @troubleshoot_performance = 1;', + 'EXECUTE sp_QuickieStore @troubleshoot_performance = 1;', version_and_date = N'version date: ' + CONVERT(nvarchar(10), @version_date, 23), thanks = diff --git a/sp_WhoIsActive Logging/01 sp_WhoIsActive Logging Views.sql b/sp_WhoIsActive Logging/01 sp_WhoIsActive Logging Views.sql index 64db769..c8b9b9e 100644 --- a/sp_WhoIsActive Logging/01 sp_WhoIsActive Logging Views.sql +++ b/sp_WhoIsActive Logging/01 sp_WhoIsActive Logging Views.sql @@ -11,7 +11,7 @@ GO /* -Copyright 2024 Darling Data, LLC +Copyright 2025 Darling Data, LLC https://www.erikdarling.com/ This will set up two views: @@ -31,7 +31,7 @@ This sets them to the correct ones. IF OBJECT_ID('dbo.sp_WhoIsActiveLogging_CreateViews') IS NULL BEGIN - EXEC ('CREATE PROCEDURE dbo.sp_WhoIsActiveLogging_CreateViews AS RETURN 138;'); + EXECUTE ('CREATE PROCEDURE dbo.sp_WhoIsActiveLogging_CreateViews AS RETURN 138;'); END; GO @@ -85,7 +85,7 @@ BEGIN LEN(@vsql) - 11 ) + N';'; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @vsql; IF NOT EXISTS @@ -243,7 +243,7 @@ BEGIN b.collection_time, b.blocked_session_count DESC;'; - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @sql; END; END; diff --git a/sp_WhoIsActive Logging/02 sp_WhoIsActiveLogging Main.sql b/sp_WhoIsActive Logging/02 sp_WhoIsActiveLogging Main.sql index 2740214..3b51031 100644 --- a/sp_WhoIsActive Logging/02 sp_WhoIsActiveLogging Main.sql +++ b/sp_WhoIsActive Logging/02 sp_WhoIsActiveLogging Main.sql @@ -11,7 +11,7 @@ GO /* -Copyright 2024 Darling Data, LLC +Copyright 2025 Darling Data, LLC https://www.erikdarling.com/ This will log sp_WhoIsActive to a table. @@ -31,7 +31,7 @@ sign that you need to update sp_WhoIsActive IF OBJECT_ID('dbo.sp_WhoIsActiveLogging_Main') IS NULL BEGIN - EXEC ('CREATE PROCEDURE dbo.sp_WhoIsActiveLogging_Main AS RETURN 138;'); + EXECUTE ('CREATE PROCEDURE dbo.sp_WhoIsActiveLogging_Main AS RETURN 138;'); END; GO @@ -103,7 +103,7 @@ BEGIN IF OBJECT_ID(@destination_table) IS NULL BEGIN - EXEC dbo.sp_WhoIsActive + EXECUTE dbo.sp_WhoIsActive @get_transaction_info = 1, @get_outer_command = 1, @get_plans = 1, @@ -123,7 +123,7 @@ BEGIN @destination_table ); - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @schema; END; @@ -131,7 +131,7 @@ BEGIN /* This logs to the table. */ - EXEC dbo.sp_WhoIsActive + EXECUTE dbo.sp_WhoIsActive @get_transaction_info = 1, @get_outer_command = 1, @get_plans = 1, @@ -142,10 +142,10 @@ BEGIN @destination_table = @destination_table; /*Execute this to prune tables*/ - EXEC dbo.sp_WhoIsActiveLogging_Retention + EXECUTE dbo.sp_WhoIsActiveLogging_Retention @RetentionPeriod = @RetentionPeriod; /*Execute this to create views*/ - EXEC dbo.sp_WhoIsActiveLogging_CreateViews; + EXECUTE dbo.sp_WhoIsActiveLogging_CreateViews; END; GO diff --git a/sp_WhoIsActive Logging/03 sp_WhoIsActiveLogging_Retention.sql b/sp_WhoIsActive Logging/03 sp_WhoIsActiveLogging_Retention.sql index 86d9f54..d5d98d7 100644 --- a/sp_WhoIsActive Logging/03 sp_WhoIsActiveLogging_Retention.sql +++ b/sp_WhoIsActive Logging/03 sp_WhoIsActiveLogging_Retention.sql @@ -11,7 +11,7 @@ GO /* -Copyright 2024 Darling Data, LLC +Copyright 2025 Darling Data, LLC https://www.erikdarling.com/ This will set delete tables older than a defined retention period, with default of 10 days. @@ -29,7 +29,7 @@ This sets them to the correct ones. IF OBJECT_ID('dbo.sp_WhoIsActiveLogging_Retention') IS NULL BEGIN - EXEC ('CREATE PROCEDURE dbo.sp_WhoIsActiveLogging_Retention AS RETURN 138;'); + EXECUTE ('CREATE PROCEDURE dbo.sp_WhoIsActiveLogging_Retention AS RETURN 138;'); END; GO @@ -81,7 +81,7 @@ BEGIN 'nvarchar(max)' ); - EXEC sys.sp_executesql + EXECUTE sys.sp_executesql @dsql; END; END; diff --git a/sp_WhoIsActive Logging/04 sp_WhoIsActive Logging Agent Job.sql b/sp_WhoIsActive Logging/04 sp_WhoIsActive Logging Agent Job.sql index f17a27a..3fa8bda 100644 --- a/sp_WhoIsActive Logging/04 sp_WhoIsActive Logging Agent Job.sql +++ b/sp_WhoIsActive Logging/04 sp_WhoIsActive Logging Agent Job.sql @@ -11,7 +11,7 @@ GO /* -Copyright 2024 Darling Data, LLC +Copyright 2025 Darling Data, LLC https://www.erikdarling.com/ This will log sp_WhoIsActive to a table. @@ -53,7 +53,7 @@ DECLARE @RetentionPeriod nvarchar(10) = N'10'; DECLARE - @command nvarchar(MAX) = N'EXEC dbo.sp_WhoIsActiveLogging_Main ' + @RetentionPeriod + N';' + @command nvarchar(MAX) = N'EXECUTE dbo.sp_WhoIsActiveLogging_Main ' + @RetentionPeriod + N';' IF NOT EXISTS @@ -65,7 +65,7 @@ IF NOT EXISTS AND category_class = 1 ) BEGIN - EXEC @ReturnCode = msdb.dbo.sp_add_category + EXECUTE @ReturnCode = msdb.dbo.sp_add_category @class = N'JOB', @type = N'LOCAL', @name = N'Data Collector'; @@ -75,7 +75,7 @@ BEGIN END; -EXEC @ReturnCode = msdb.dbo.sp_add_job +EXECUTE @ReturnCode = msdb.dbo.sp_add_job @job_name = N'Log sp_WhoIsActive To A Daily Table', @enabled = 1, @notify_level_eventlog = 0, @@ -106,7 +106,7 @@ IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback; -EXEC @ReturnCode = msdb.dbo.sp_add_jobstep +EXECUTE @ReturnCode = msdb.dbo.sp_add_jobstep @job_id = @jobId, @step_name = N'Log sp_WhoIsActive To A Daily Table', @step_id = 1, @@ -126,14 +126,14 @@ EXEC @ReturnCode = msdb.dbo.sp_add_jobstep IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback; - EXEC @ReturnCode = msdb.dbo.sp_update_job + EXECUTE @ReturnCode = msdb.dbo.sp_update_job @job_id = @jobId, @start_step_id = 1; IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback; - EXEC @ReturnCode = msdb.dbo.sp_add_jobschedule + EXECUTE @ReturnCode = msdb.dbo.sp_add_jobschedule @job_id = @jobId, @name = N'Log sp_WhoIsActive To A Daily Table Every Minute', @enabled = 1, @freq_type = 4, @@ -151,7 +151,7 @@ IF (@@ERROR <> 0 OR @ReturnCode <> 0) IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback; - EXEC @ReturnCode = msdb.dbo.sp_add_jobserver + EXECUTE @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @jobId, @server_name = N'(local)';