CREATE PROCEDURE ExclusiveInsuranceCheckTtac @PrescriptionId bigint 
AS 
SELECT Radif Row, GoodsCode, Name1 GoodsName, K_Qty1 Qty  FROM dbo.TmpDrugHavaleh WITH (NOLOCK)
INNER JOIN dbo.KalaId WITH (NOLOCK) ON KalaId.K_Code = TmpDrugHavaleh.K_Code
INNER JOIN dbo.TmpDrugH WITH (NOLOCK) ON TmpDrugH.Id_Havaleh = TmpDrugHavaleh.Id_Havaleh
INNER JOIN dbo.ExclusiveInsuranceCode WITH (NOLOCK) ON GoodsCode = Kalaid.K_Code AND Sazman_Code = InsuranceCode AND ISNULL(HasTTAC,0) = 1
WHERE dbo.TmpDrugH.Id_Havaleh = @PrescriptionId
ORDER BY Row

