我有要升级的程序,它在插入之前在拾取数据表中为客户插入新记录
我正在尝试更新它,以便它检查客户端 StatusID 是否在(1、2、6)中。到目前为止我有这个
alter PROCEDURE dbo.InsertPickup
@ClientID int, --Required ClientID and PickupDate
@PickupDate date
AS
IF NOT EXISTS (SELECT * FROM Pickup
WHERE ClientID = @ClientID
AND MONTH(PickupDate) = MONTH(@PickupDate)
AND YEAR(PickupDate) = YEAR(@PickupDate) )
if exists (select * from clients where statusid in (1,2,6))
INSERT INTO Pickup (ClientID, PickupDate)
VALUES (@ClientID, @PickupDate)
但是如果例如状态ID = 5或3或4的客户端,它仍然插入记录是不对的