Skip to content

Commit d51b0ea

Browse files
authored
Merge pull request #3641 from erikdarlingdata/dev
Issue 3640
2 parents 68f420f + 77ebf85 commit d51b0ea

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

sp_BlitzLock.sql

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,7 +1255,7 @@ BEGIN
12551255
END;
12561256

12571257
/* If table target */
1258-
IF @TargetSessionType = 'table'
1258+
IF LOWER(@TargetSessionType) = N'table'
12591259
BEGIN
12601260
SET @d = CONVERT(varchar(40), GETDATE(), 109);
12611261
RAISERROR('Inserting to #deadlock_data from table source %s', 0, 1, @d) WITH NOWAIT;
@@ -1273,9 +1273,19 @@ BEGIN
12731273
SELECT TOP (1)
12741274
@xe = xe.e.exist(''.''),
12751275
@xd = xd.e.exist(''.'')
1276-
FROM [master].[dbo].[bpr] AS x
1277-
OUTER APPLY x.[bpr].nodes(''/event'') AS xe(e)
1278-
OUTER APPLY x.[bpr].nodes(''/deadlock'') AS xd(e)
1276+
FROM ' +
1277+
QUOTENAME(@TargetDatabaseName) +
1278+
N'.' +
1279+
QUOTENAME(@TargetSchemaName) +
1280+
N'.' +
1281+
QUOTENAME(@TargetTableName) +
1282+
N' AS x
1283+
OUTER APPLY x.' +
1284+
QUOTENAME(@TargetColumnName) +
1285+
N'.nodes(''/event'') AS xe(e)
1286+
OUTER APPLY x.' +
1287+
QUOTENAME(@TargetColumnName) +
1288+
N'.nodes(''/deadlock'') AS xd(e)
12791289
OPTION(RECOMPILE);
12801290
';
12811291

@@ -1412,6 +1422,7 @@ BEGIN
14121422
LEFT JOIN #t AS t
14131423
ON 1 = 1
14141424
WHERE @xe = 1
1425+
OR LOWER(@TargetSessionType) <> N'table'
14151426

14161427
UNION ALL
14171428

0 commit comments

Comments
 (0)