You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
WHERE i.is_not_trusted = 1 AND i.is_not_for_replication = 0
840
867
) AS r
841
868
ON 1 = 1
869
+
WHERE TableName is not null
842
870
';
843
-
/*
844
-
The [SRA] database has foreign keys that were probably disabled, data was changed, and then the key was enabled again. Simply enabling the key is not enough for the optimizer to use this key - we have to alter the table using the WITH CHECK CHECK CONSTRAINT parameter. (https://www.brentozar.com/blitz/foreign-key-trusted/ ). It turns out this can have a huge performance impact on queries, too, because SQL Server wont use untrusted constraints to build better execution plans.
SET @s ='IF OBJECT_ID('''+@tableName+''') IS NULL BEGIN '+@s+'; CREATE CLUSTERED INDEX [CI_WhoIsActive_ResultSet] ON '+@tableName+' ( [collection_time] ASC, session_id ); END'
28
+
SET @s ='IF OBJECT_ID('''+@tableName+''') IS NULL BEGIN '+@s+'; CREATE CLUSTERED INDEX [CI_WhoIsActive] ON '+@tableName+' ( [collection_time] ASC, session_id ); END'
27
29
EXEC(@s);
28
30
31
+
declare @currrent_date datetime2=getdate();
32
+
while (@start_loop =1and @currrent_date >DATEADD(HOUR,-2,GETDATE()))
Copy file name to clipboardExpand all lines: ErrorLogs/QRY-Search-ErrorLog.sql
+28-8
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,21 @@
1
+
-- Check-SQLServerAvailability
2
+
declare @time datetime;
3
+
select @time =d.create_date
4
+
FROMsys.databasesas d
5
+
WHEREd.name='tempdb';
6
+
SELECT@@servernameas srv, @time as server_uptime, DATEDIFF(MINUTE,@time,GETDATE()) AS [up_time(minutes)], DATEDIFF(HOUR,@time,GETDATE()) AS [up_time(hours)];
1
7
2
-
declare @start_time datetime, @end_time datetime;
3
-
set @start_time ='2020-08-22 03:00:00.000'-- August 22, 2020 05:16:00
0 commit comments