SQL Server Error Messages - Msg 313¶
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¶
- SQL Server Error Messages - Error Msg 174 - The dateadd function requires 3 argument(s).
- SQL Server Error Messages - Error Msg 237 - There is insufficient result space to convert a money value to bigint / int / smallint / tinyint.
- SQL Server Error Messages - Error Msg 8144 - Procedure or function Stored Procedure or Function Name has too many arguments specified.