From ff8273c136b24c84df4c81ae0a80bdba156fee1c Mon Sep 17 00:00:00 2001 From: RG Date: Sat, 27 Jul 2024 02:39:04 +0100 Subject: [PATCH] Added more checks for database_id with the new tables. --- sp_QuickieStore/sp_QuickieStore.sql | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sp_QuickieStore/sp_QuickieStore.sql b/sp_QuickieStore/sp_QuickieStore.sql index cab532b..13a9f6c 100644 --- a/sp_QuickieStore/sp_QuickieStore.sql +++ b/sp_QuickieStore/sp_QuickieStore.sql @@ -5071,14 +5071,16 @@ CROSS APPLY SELECT @sql += N' JOIN #plan_ids_with_query_hashes AS hashes - ON qsrs.plan_id = hashes.plan_id' + ON qsrs.plan_id = hashes.plan_id + AND hashes.database_id = @database_id' END; IF @sort_order_is_a_wait = 1 BEGIN SELECT @sql += N' JOIN #plan_ids_with_total_waits AS waits - ON qsrs.plan_id = waits.plan_id' + ON qsrs.plan_id = waits.plan_id + AND waits.database_id = @database_id' END; SELECT @@ -7513,14 +7515,16 @@ FROM SELECT @sql += N' JOIN #plan_ids_with_query_hashes AS hashes - ON qsrs.plan_id = hashes.plan_id' + ON qsrs.plan_id = hashes.plan_id + AND hashes.database_id = @database_id' END; IF @sort_order_is_a_wait = 1 BEGIN SELECT @sql += N' JOIN #plan_ids_with_total_waits AS waits - ON qsrs.plan_id = waits.plan_id' + ON qsrs.plan_id = waits.plan_id + AND waits.database_id = @database_id' END; SELECT