In Microsoft SQL Server 2016, created a function with default argument, but it is not working as expected.
When calling select dbo.myTest(2)
, it is giving error:
An insufficient number of arguments were supplied for the procedure or function dbo.myTest.
CREATE FUNCTION dbo.myTest(@num1 INT, @num2 int = 1 )
RETURNS int
AS
BEGIN
RETURN @num2
END
I am expecting to call the function with 1 argument also, What is it I am doing wrong here?