Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 stored proc parameter type mismatch

Author  Topic 

farmstrong
Starting Member

1 Post

Posted - 2013-07-30 : 23:15:58
When my classic asp calls stored proc, parameter types are not specified. This is fine most of time, but if this funcionality is highly used, applications gets error sometimes.

Error:
sql native client procedure or function [sp name] expects parameter [parameter name], which was not supplied.

This is not a replicatable issue, but happens from time to time.
I guess the problem is SQL server guesses parameter type every time, and there is small chance it guesses incorrectly.

I can fix this issue by specifying parameter types, but there are hundreds of places to be fixed.

Is there a better way to fix this? SQL server connection settings?
Thanks you.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-07-31 : 01:28:01
Nope. As the error says the issue is because sql server expects a parameter which you've defined in the stored procedure/function but you've not included a value for it in the procedure/function call.
My guess is one scenario where this can happen is you may have optional parameter which you've created in procedure/function and may be ommiting the values while calling it. In such cases, you need to make sure you specify a default value for them in stored procedure/function definition to avoid this error. Also you need to explicitly pass parameternames in procedure/function like

EXEC SToredProcedure @ParamName=value1,...

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -