The following SQL compiles in Sybase ASE and MS SQL Server without problems:
go
create proc foo
@foo1 int
as
select @foo1
go
create proc bar
@bar1 int
as
exec foo @foo1=@bar1, @foo2=@bar1
go
It runs without issue in Sybase ASE, but in MS SQL Server complains:
Msg 8144, Level 16, State 2, Procedure foo, Line 11
Procedure or function foo has too many arguments specified.
Is it possible to tell MS SQL Server to ignore this warning? And if not, is it possible to tell MS SQL Server to break when compiling stored procedures that calls other procedures with too many arguments? It is potentially dangerous when we will only learn of these issues when the procedures are actually called.
This code is supposed to work both in Sybase ASE and MS SQL Server, and we have so far been using the luxury of Sybase's relaxed rules, as we are now adding support for MS SQL Server.
As I mentioned below, the problem is not optional parameters. It is prediction about stored procedures. I don't mind solving the issue by only calling stored procedures with the correct number of parameters or adding dummy parameters to stored procedures, I just want MS SQL Server to tell me at compile time, not at runtime. Since MS SQL Server actually verifies whether or not a procedure exists (it gives a warning if it does not, although I'd prefer if it failed like Sybase ASE), why can't it check its parameters at the same time?