IF @object_type= '22' AND @transaction_type in ('A')
BEGIN
IF EXISTS (select r.DocEntry from opor r inner join por1 r1 on r.docentry=r1.DocEntry
where r1.Quantity > ISNULL(r1.YOUR_UDF_FIELD, 0) AND r.DOCENTRY= @list_of_cols_val_tab_del)
BEGIN
SELECT @Error = 1, @error_message = 'Change the Quantity'
END
END
It is better to add ISNULL to make sure the value is comparable.