Above the call to this stored procedure is another call to a different stored procedure. The first procedure will assign something to @NewIdentifier
if it needs to, otherwise I need to use the default SaleId
.
exec myStoredProc @SaleId = ISNULL(@NewIdentifier, @SaleId)
It works if I do it this way
declare @Id int
set @Id = ISNULL(@NewIdentifier, @SaleId)
exec myStoredProc @SaleId = @Id
Is it possible to use ISNULL
in the assignment of a stored procedure parameter? I'm not sure what is invalid about this syntax.
Another time ISNULL() will not work is if the data types are not compatible. In SQL Server, the ISNULL() function tries to convert the lower precedence data types into a higher precedence data types. If ISNULL() is not able to convert the data type, it returns an error message.
Returns a Boolean value that indicates whether an expression contains no valid data (Null). Syntax. IsNull ( expression ) The required expressionargument is a Variant containing a numeric expression or string expression.
SQL Server ISNULL() FunctionThe ISNULL() function returns a specified value if the expression is NULL. If the expression is NOT NULL, this function returns the expression.
We use IS NULL to identify NULL values in a table. For example, if we want to identify records in the employee table with NULL values in the Salary column, we can use IS NULL in where clause.
The parameter must be a constant or a variable. It cannot be an expression.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With