New transaction is not allowed because there are other threads running in the session. Error In SQL SERVER

Viewed 1759

i am not sure whether anyone familiar of this error.

The below is the SP have linked server used in it.

ALTER PROCEDURE [dbo].[USP_SEMI_NEW_Pepsi] 
AS 

BEGIN 

SET NOCOUNT ON 
SET XACT_ABORT ON 




IF OBJECT_ID('dbo.SEMI_NEW_Pepsi', 'U') IS NOT NULL
DROP TABLE dbo.SEMI_NEW_Pepsi;


SELECT 
          Pepsi.APPID
         ,Pepsi.Action
         ,Pepsi.Brand
        ,ISNULL (BV.BaseID,'') BaseID
        ,isnull(cast(Pepsi.QuantityID as varchar(150)),'')QuantityID

INTO dbo.SEMI_NEW_Pepsi

FROM 
dbo.PREP_NEW_Pepsi Pepsi
LEFT OUTER  JOIN linkedserver.dbo.Quantity sub ON  sub.QuantityID =     Pepsi.SubQuantityID
INNER  JOIN     linkedserver.dbo.Base BV ON  BV.BaseID = Pepsi.BaseID

WHERE CASE WHEN(
(BV.BaseID IS NULL AND Pepsi.BaseID > '')
 (sub.QuantityID IS NULL AND Pepsi.QuantityID > '')
END

When i am trying to execute this as Exec [USP_SEMI_NEW_Pepsi]

i am getting error as given below.

Msg 3988, Level 16, State 1, Line 1 New transaction is not allowed because there are other threads running in the session.

but when i executed only this part AND not calling SP, i am not getting any error.

SELECT       
 Pepsi.APPID
     ,Pepsi.Action
     ,Pepsi.Brand
    ,ISNULL (BV.BaseID,'') BaseID
        ,isnull(cast(Pepsi.QuantityID as varchar(150)),'')QuantityID

  INTO dbo.SEMI_NEW_Pepsi

    FROM   
    dbo.PREP_NEW_Pepsi Pepsi
    LEFT OUTER  JOIN linkedserver.dbo.Quantity sub ON sub.QuantityID =Pepsi.SubQuantityID
    INNER  JOIN  linkedserver.dbo.Base BV ON  BV.BaseID = Pepsi.BaseID

   WHERE CASE WHEN(
    (BV.BaseID IS NULL AND Pepsi.BaseID > '')
    (sub.QuantityID IS NULL AND Pepsi.QuantityID > '')

This is running absolutely fine, not giving any error, but same thing calling through SP is throwing error.

May anyone please help me how to rectify this please.

Linked server used in the code

1 Answers
Related