Monday, July 27, 2015

Procedure or function ' ' expects parameter ' ', which was not supplied.

Suppose you have created a stored procedure which takes input a string parameter and returns some data. You think that you have correctly passed the parameter value but still get the following error:

Procedure or function 'GetUserData' expects parameter '@UserName', which was not supplied.

You are confused that the parameter is passed but still error is occurring. But, there is another reason when this can occur. The other issue is that we are passing NULL value in the parameter. In such a case, it is considered as no parameter being passed into it. 

So solution is:
  • Pass the proper value to the parameter OR 
  • Set default value to be NULL for that parameter, in the stored procedure.
Happy SQL'ing...!!!

No comments:

Post a Comment