我正在创建一个存储过程,我需要某种类型的变量包含多个值。我试过使用表变量,但这不是我要找的。这样做的原因是因为我必须从选择查询中检查多个值,然后对这些值使用 if 语句。
我需要变量的代码是:
If @SplitVal = 1
Begin
Insert into SpecDetailsExt (SrecId, SplitVal, Acknowledged,Required, [Drawings Produced])
Select DISTINCT SpecDetails.SrecId, '1', @MoveToOrder, @RequiredDate, @Drawings
FROM SpecDetails INNER JOIN Products ON SpecDetails.ProductRef = Products.CDF_Code_Tx
WHERE (SpecDetails.QuoteNo = @Qno)
End
ELSE
Begin
Insert into SpecDetailsExt (SrecId, SplitVal, Acknowledged, Required, [Drawings Produced])
Select DISTINCT SpecDetails.SrecId, '1', @MoveToOrder, @RequiredDate, @Drawings
FROM SpecDetails INNER JOIN Products ON SpecDetails.ProductRef = Products.CDF_Code_Tx
WHERE (SpecDetails.QuoteNo = @Qno)
Insert into SpecDetailsExt (SrecId, SplitVal, Acknowledged, Required, [Drawings Produced])
Select DISTINCT SpecDetails.SrecId, '2', @MoveToOrder, @RequiredDate, @Drawings
FROM SpecDetails
INNER JOIN Products ON SpecDetails.ProductRef = Products.CDF_Code_Tx
WHERE (SpecDetails.QuoteNo = @Qno)
End