Skip to content

Commit ae935df

Browse files
authored
Merge pull request #3576 from BrentOzarULTD/3566_sp_BlitzLock_error
#3566 sp_BlitzLock better qualify synonym
2 parents abcc94d + 156fa58 commit ae935df

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

sp_BlitzLock.sql

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3675,8 +3675,9 @@ BEGIN
36753675
SET STATISTICS XML ON;
36763676
END;
36773677

3678-
INSERT INTO
3679-
DeadLockTbl
3678+
SET @StringToExecute = N'
3679+
3680+
INSERT INTO ' + QUOTENAME(DB_NAME()) + N'..DeadLockTbl
36803681
(
36813682
ServerName,
36823683
deadlock_type,
@@ -3720,7 +3721,8 @@ BEGIN
37203721
deadlock_graph
37213722
)
37223723
EXEC sys.sp_executesql
3723-
@deadlock_result;
3724+
@deadlock_result;'
3725+
EXEC sys.sp_executesql @StringToExecute, N'@deadlock_result NVARCHAR(MAX)', @deadlock_result;
37243726

37253727
IF @Debug = 1
37263728
BEGIN
@@ -3734,8 +3736,9 @@ BEGIN
37343736
SET @d = CONVERT(varchar(40), GETDATE(), 109);
37353737
RAISERROR('Findings to table %s', 0, 1, @d) WITH NOWAIT;
37363738

3737-
INSERT INTO
3738-
DeadlockFindings
3739+
SET @StringToExecute = N'
3740+
3741+
INSERT INTO ' + QUOTENAME(DB_NAME()) + N'..DeadlockFindings
37393742
(
37403743
ServerName,
37413744
check_id,
@@ -3753,7 +3756,8 @@ BEGIN
37533756
df.finding
37543757
FROM #deadlock_findings AS df
37553758
ORDER BY df.check_id
3756-
OPTION(RECOMPILE);
3759+
OPTION(RECOMPILE);'
3760+
EXEC sys.sp_executesql @StringToExecute;
37573761

37583762
RAISERROR('Finished at %s', 0, 1, @d) WITH NOWAIT;
37593763

0 commit comments

Comments
 (0)