A friend of mine asked me a question regarding SQL and default parameters.

Here is what he ran into:

create function foo
(
      @required int, 
      @optional int = 0
)
returns int
as
begin
      return(select @required)
end
go

But if he ran it with this:

select [dbo].foo(2)

He would get an error saying insufficient number of arguments where passed in.  Here is what he should have done:

select [dbo].ff(2, DEFAULT)
Tags [ Coding ]