I am validating a stored procedure parameter
declare @RequestAmount varchar(21)
IF(@RequestAmount IS NULL OR RTRIM(LTRIM(@RequestAmount)) = '') select 'value required'
I also check if amount is zero, amount is greater than 1 lakh etc.,
I also have a json as input parameter, I loop through json and check if Productcreditlimit value is less than request amount but this check overrides all the validation done for request amount and considers request amount as zero only.
DECLARE @json NVARCHAR(MAX) = N'[{ " ID":"1", "Product":"A", "ProductCreditLimit":"12357.00", "AccountHolder":"29150820", "ProductNumber":"00098683"},
{ "ID":"2", "Product":"B", "ProductCreditLimit":"3434.00", "AccountHolder":"73247202", "ProductNumber":"00098706"},
{ "ID":"3", "Product":"C", "ProductCreditLimit":"1000.00", "AccountHolder":"73212071", "ProductNumber":"00098684"},
{ "ID":"4", "Product":"D", "ProductCreditLimit":"34000.00", "AccountHolder":"73247205", "ProductNumber":"343434444"}]}';