Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

Query Causing Blocking, Locks Table for 1000 Seconds, Help Needed!

$
0
0
Help needed from the guru's here! I have a sql snippet from a 3rd party application that will not complete its transaction. The SELECT statement executes but does not finish. Instead the statement just sits in AWAITING COMMAND for 1000 seconds then dies, thus killing the UPDATE statement that is supposed to follow.The CROSS JOIN and CROSS APPLY seem suspect. Can anyone spot where this query goes wrong?[code="sql"]( @p0 DATETIME, @p1 INT, @p2 INT, @p3 NVARCHAR(4000), @p4 INT, @p5 NVARCHAR(4000), @p6 DATETIME, @p7 DATETIME, @p8 INT, @p9 INT, @p10 INT, @p11 INT )SELECT [t4].[Destination], [t4].[Message], [t4].[OutboxAN], [t4].[OutboxStatusAN], [t4].[OutboxTypeAN], [t4].[Subject], [t4].[Fax], [t4].[FileName], [t4].[OutBoxData] AS [OutBoxData1], [t4].[OutBoxDataAN], [t4].[Type], [t4].[ClientReferenceID], [t4].[value] AS [CompanyClientMemberID], [t4].[value2] AS [ContactClientMemberID], [t4].[value3] AS [ReportType], [t4].[value4] AS [CompanyClientRoleID]FROM ( SELECT [t0].[Destination], [t0].[Message], [t0].[OutboxAN], [t0].[OutboxStatusAN], [t0].[OutboxTypeAN], [t0].[Subject], [t1].[Fax], [t1].[FileName], [t1].[OutBoxData], [t1].[OutBoxDataAN], [t1].[Type], [t0].[ClientReferenceID], ( CASE WHEN [t0].[CompanyClientMemberID] IS NULL THEN @p1 ELSE [t0].[CompanyClientMemberID] END ) AS [value], ( CASE WHEN [t0].[ContactClientMemberID] IS NULL THEN @p2 ELSE [t0].[ContactClientMemberID] END ) AS [value2], ( CASE WHEN [t0].[ReportType] IS NULL THEN CONVERT(NVARCHAR(50), @p3) ELSE [t0].[ReportType] END ) AS [value3], ( CASE WHEN [t3].[test] IS NULL THEN @p4 ELSE [t3].[ClientRoleID] END ) AS [value4], [t1].[OutBoxAN] AS [OutBoxAN2] FROM [dbo].[Outbox] AS [t0] CROSS JOIN [dbo].[OutBoxData] AS [t1] LEFT JOIN ( SELECT 1 AS [test], [t2].[ClientMemberID], [t2].[ClientRoleID], [t2].[EndEffectiveDate] FROM [dbo].[ClientMember] AS [t2] ) AS [t3] ON ([t0].[CompanyClientMemberID] IS NOT NULL) AND ([t3].[ClientMemberID] = ([t0].[CompanyClientMemberID])) AND ([t3].[EndEffectiveDate] = @p0) ) AS [t4]CROSS APPLY ( SELECT TOP (1) [t10].[test] FROM ( SELECT NULL AS [EMPTY] ) AS [t5] LEFT JOIN ( SELECT 1 AS [test] FROM [dbo].[MemberOther] AS [t6], [dbo].[ClientMember] AS [t7], [dbo].[ClientRole] AS [t8], [dbo].[ClientRole] AS [t9] WHERE ([t9].[ClientRoleID] = [t4].[value4]) AND ([t6].[TheValue] = 1) AND ([t6].[Description] = @p5) AND ([t6].[EndEffectiveDate] = @p6) AND ([t7].[ClientMemberID] = [t6].[ClientMemberID]) AND ([t7].[EndEffectiveDate] = @p7) AND ([t8].[ClientRoleID] = [t7].[ClientRoleID]) AND ([t9].[ClientID] = [t8].[ClientID]) AND ([t9].[DefaultBeginLevel] = @p8) ) AS [t10] ON 1 = 1 ) AS [t11]WHERE ( ([t11].[test] IS NULL) OR ( ([t11].[test] IS NOT NULL) AND ([t4].[OutboxTypeAN] <> @p9) AND ([t4].[OutboxTypeAN] <> @p10) ) ) AND ([t4].[OutboxStatusAN] = @p11) AND ([t4].[OutBoxAN2] = ([t4].[OutboxAN]))[/code]

Viewing all articles
Browse latest Browse all 3145

Trending Articles