Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4244d71

Browse files
Logic chage
I was doing something kinda dumb witht he update/insert logic. We want to do both no matter what.
1 parent abee43a commit 4244d71

File tree

2 files changed

+55
-52
lines changed

2 files changed

+55
-52
lines changed

‎sp_BlitzCache.sql

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3175,32 +3175,35 @@ SELECT @@SPID AS SPID,
31753175
FROM #conversion_info AS ci
31763176
OPTION ( RECOMPILE );
31773177

3178-
IF EXISTS ( SELECT *
3179-
FROM #stored_proc_info AS sp
3180-
JOIN #variable_info AS vi
3181-
ON (sp.proc_name = 'adhoc' AND sp.QueryHash = vi.QueryHash)
3182-
OR (sp.proc_name <> 'adhoc' AND sp.SqlHandle = vi.SqlHandle)
3183-
AND sp.variable_name = vi.variable_name )
3184-
BEGIN
3185-
RAISERROR(N'Updating variables', 0, 1) WITH NOWAIT;
3186-
UPDATE sp
3187-
SET sp.variable_datatype = vi.variable_datatype,
3188-
sp.compile_time_value = vi.compile_time_value
3189-
FROM #stored_proc_info AS sp
3190-
JOIN #variable_info AS vi
3191-
ON (sp.proc_name = 'adhoc' AND sp.QueryHash = vi.QueryHash)
3192-
OR (sp.proc_name <> 'adhoc' AND sp.SqlHandle = vi.SqlHandle)
3193-
AND sp.variable_name = vi.variable_name
3194-
OPTION ( RECOMPILE );
3195-
END
3196-
ELSE
3197-
BEGIN
3198-
RAISERROR(N'Inserting variables', 0, 1) WITH NOWAIT;
3199-
INSERT #stored_proc_info ( SPID, SqlHandle, QueryHash, variable_name, variable_datatype, compile_time_value, proc_name )
3200-
SELECT vi.SPID, vi.SqlHandle, vi.QueryHash, vi.variable_name, vi.variable_datatype, vi.compile_time_value, vi.proc_name
3201-
FROM #variable_info AS vi
3202-
OPTION ( RECOMPILE );
3203-
END
3178+
3179+
3180+
RAISERROR(N'Updating variables inserted procs', 0, 1) WITH NOWAIT;
3181+
UPDATE sp
3182+
SET sp.variable_datatype = vi.variable_datatype,
3183+
sp.compile_time_value = vi.compile_time_value
3184+
FROM #stored_proc_info AS sp
3185+
JOIN #variable_info AS vi
3186+
ON (sp.proc_name = 'adhoc' AND sp.QueryHash = vi.QueryHash)
3187+
OR (sp.proc_name <> 'adhoc' AND sp.SqlHandle = vi.SqlHandle)
3188+
AND sp.variable_name = vi.variable_name
3189+
OPTION ( RECOMPILE );
3190+
3191+
3192+
RAISERROR(N'Inserting variables for other procs', 0, 1) WITH NOWAIT;
3193+
INSERT #stored_proc_info
3194+
( SPID, SqlHandle, QueryHash, variable_name, variable_datatype, compile_time_value, proc_name )
3195+
SELECT vi.SPID, vi.SqlHandle, vi.QueryHash, vi.variable_name, vi.variable_datatype, vi.compile_time_value, vi.proc_name
3196+
FROM #variable_info AS vi
3197+
WHERE NOT EXISTS
3198+
(
3199+
SELECT *
3200+
FROM #stored_proc_info AS sp
3201+
WHERE (sp.proc_name = 'adhoc' AND sp.QueryHash = vi.QueryHash)
3202+
OR (sp.proc_name <> 'adhoc' AND sp.SqlHandle = vi.SqlHandle)
3203+
AND sp.variable_name = vi.variable_name
3204+
)
3205+
OPTION ( RECOMPILE );
3206+
32043207

32053208
RAISERROR(N'Updating procs', 0, 1) WITH NOWAIT;
32063209
UPDATE s

‎sp_BlitzQueryStore.sql

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3034,32 +3034,32 @@ IF EXISTS ( SELECT 1
30343034
FROM #conversion_info AS ci
30353035
OPTION ( RECOMPILE );
30363036

3037-
IFEXISTS ( SELECT*
3038-
FROM #stored_proc_info AS sp
3039-
JOIN #variable_info AS vi
3040-
ON (sp.proc_name = 'adhoc'ANDsp.query_hash=vi.query_hash)
3041-
OR (sp.proc_name<>'adhoc'AND sp.sql_handle=vi.sql_handle)
3042-
ANDsp.variable_name= vi.variable_name )
3043-
BEGIN
3044-
RAISERROR(N'Updating variables', 0, 1) WITHNOWAIT;
3045-
UPDATE sp
3046-
SETsp.variable_datatype=vi.variable_datatype,
3047-
sp.compile_time_value=vi.compile_time_value
3048-
FROM #stored_proc_info AS sp
3049-
JOIN #variable_info AS vi
3050-
ON (sp.proc_name='adhoc'ANDsp.query_hash=vi.query_hash)
3051-
OR (sp.proc_name<>'adhoc'ANDsp.sql_handle=vi.sql_handle)
3052-
ANDsp.variable_name= vi.variable_name
3053-
OPTION ( RECOMPILE );
3054-
END
3055-
ELSE
3056-
BEGIN
3057-
RAISERROR(N'Inserting variables', 0, 1) WITHNOWAIT;
3058-
INSERT #stored_proc_info ( sql_handle, query_hash, variable_name, variable_datatype, compile_time_value, proc_name )
3059-
SELECTvi.sql_handle, vi.query_hash, vi.variable_name, vi.variable_datatype, vi.compile_time_value, vi.proc_name
3060-
FROM #variable_info AS vi
3061-
OPTION ( RECOMPILE );
3062-
END
3037+
RAISERROR(N'Updating variables inserted procs', 0, 1) WITHNOWAIT;
3038+
UPDATE sp
3039+
SETsp.variable_datatype= vi.variable_datatype,
3040+
sp.compile_time_value = vi.compile_time_value
3041+
FROM #stored_proc_info AS sp
3042+
JOIN #variable_info AS vi
3043+
ON (sp.proc_name='adhoc'ANDsp.query_hash=vi.query_hash)
3044+
OR (sp.proc_name<>'adhoc'ANDsp.sql_handle=vi.sql_handle)
3045+
AND sp.variable_name=vi.variable_name
3046+
OPTION ( RECOMPILE );
3047+
3048+
3049+
RAISERROR(N'Inserting variables for other procs', 0, 1) WITHNOWAIT;
3050+
INSERT #stored_proc_info
3051+
( sql_handle, query_hash, variable_name, variable_datatype, compile_time_value, proc_name )
3052+
SELECTvi.sql_handle, vi.query_hash, vi.variable_name, vi.variable_datatype, vi.compile_time_value, vi.proc_name
3053+
FROM #variable_info AS vi
3054+
WHERENOTEXISTS
3055+
(
3056+
SELECT*
3057+
FROM #stored_proc_info AS sp
3058+
WHERE (sp.proc_name='adhoc'ANDsp.query_hash=vi.query_hash)
3059+
OR (sp.proc_name<>'adhoc'ANDsp.sql_handle=vi.sql_handle)
3060+
ANDsp.variable_name= vi.variable_name
3061+
)
3062+
OPTION ( RECOMPILE );
30633063

30643064
RAISERROR(N'Updating procs', 0, 1) WITH NOWAIT;
30653065
UPDATE s

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /