create a table value function for getting packet info:
CREATE FUNCTION dbo.SPViewMTOByLineIdAndTestPackageId(@PackId int)
RETURNS @packInfo TABLE
(
Shortage int ,
totalIMIV int ,
TotalMIV int ,
JobTitle int ,
TotalMRC int
)
AS
-- Returns the first name, last name, job title, and contact type for the specified contact.
BEGIN
SELECT *,isnull(dbo.ReturnShortageByItemCodeLinePackage(LineId,TestPackageId,MaterialDescriptionId),0) As Shortage
,isnull(dbo.ReturnTotalIMIVByLineIdAndTestPackIdAndMaterialDescriptionId(LineId,TestPackageId,MaterialDescriptionId),0) as totalIMIV
,isnull(dbo.ReturnTotalMIVByLineIdAndTestPackIdAndMaterialDescriptionId(LineId,TestPackageId,MaterialDescriptionId),0) as TotalMIV
,isnull(dbo.ReturnTotalMRCByLineIdAndTestPackIdAndMaterialDesriptionId(LineId,TestPackageId,MaterialDescriptionId),0) as TotalMRC
,isnull(dbo.WarehouseByMaterialdesciptionId(MaterialDescriptionId),0) As Warehouse
from
dbo.ViewMTO where TestPackageId=@PackId
END
Modify your second proc as below :
Create PROCEDURE secondSP
AS
declare @a nvarchar(max)
BEGIN
select @a=shortage from dbo.SPViewMTOByLineIdAndTestPackageId(1)
END
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…