Skip Navigation Links
Home
Articles
SQL Server 2012
SQL Server 2014
SQL Server 2016
FAQ
Practice Test
Tip of the Day : SQL Server 2012 Management Studio Keyboard Shortcuts - Microsoft IntelliSense
Error Messages
Home > SQL Server Error Messages > Msg 313 - An insufficient number of arguments were supplied for the procedure or function Stored Procedure or Function Name.
SQL Server Error Messages - Msg 313 - An insufficient number of arguments were supplied for the procedure or function Stored Procedure or Function Name.

Error Message

Server: Msg 313, Level 16, State 2, Line 1
An insufficient number of arguments were supplied for
the procedure or function Stored Procedure or Function
Name.

Causes:

As the message describes, this error is encountered when you are passing arguments or parameters to a function or stored procedure which is less than what the function or stored procedure is expecting.

To illustrate, let’s say you have the following function definition:

CREATE FUNCTION [dbo].[ufn_Concat]
( @pString1 VARCHAR(10), @pString2 VARCHAR(10), @pString3 VARCHAR(10) )
RETURNS VARCHAR(30)
AS
BEGIN
    RETURN ISNULL(@pString1 + ' ', '') + 
           ISNULL(@pString2 + ' ', '') +
           ISNULL(@pString3, '')
END

This function expects 3 arguments, namely @pString1, @pString2 and @pString3.  To use this function, you do the following:

SELECT [dbo].[ufn_Concat] ( [FirstName], [MiddleName], [LastName] ) AS [FullName]
FROM [dbo].[Customers]

The error will be encountered you don’t pass 3 arguments or parameters to the function, as follows:

SELECT [dbo].[ufn_Concat] ( [FirstName], [LastName] ) AS [FullName]
FROM [dbo].[Customers]
Server: Msg 313, Level 16, State 2, Line 1
An insufficient number of arguments were supplied for the procedure or function dbo.ufn_Concat.

Solution / Work Around:

To avoid this error from happening, always make sure that you pass the same number of arguments that a stored procedure or function is expecting.  To know the parameters expected by a stored procedure, you can use the sp_help system stored procedure and pass the name of the stored procedure as the parameter.

Related Articles :