IF (Select Count(*) FROM  AllotmentPaymentXTAB (NOLOCK)) > 0
	UPDATE AllotmentPaymentXTAB
	SET FK_Warenumber = w.Warenumber
	FROM AllotmentPaymentXTAB apx (nolock)
	INNER JOIN ware w (nolock) on apx.FK_Warenumber + 1 = w.SortNumber 
	WHERE (W.Payment > 0 OR W.Type in (4,29))