T-SQL – function with default parameters

you have to call it like this

SELECT dbo.CheckIfSFExists(23, default)

From Technet:

When a parameter of the function has a default value, the keyword
DEFAULT must be specified when the function is called in order to
retrieve the default value. This behaviour is different from using
parameters with default values in stored procedures in which omitting
the parameter also implies the default value. An exception to this
behaviour is when invoking a scalar function by using the EXECUTE
statement. When using EXECUTE, the DEFAULT keyword is not required.

Leave a Comment

tech