views:

30

answers:

2

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.

A: 

Is it possible that the '=' operator has lower precedence than '(' ? If so, it would be parsed as exec myStoredProc (@SaleId = ISNULL) (@NewIdentifier, @SaleId), which would be a syntax error.

Mike Hewett
+3  A: 

The parameter must be a constant or a variable. It cannot be an expression.

Joe Stefanelli
Ah, I see. Thanks Joe.
Brandon