Home | User-Defined Functions | Tips & Tricks | SQL Server 2005 | SQL Server 2008 | Forums | FAQ | Practice Test |    
Tip of the Day : Convert Oracle Math Functions to SQL Server Math Functions
Home > SQL Server Error Messages > Msg 8144 - Procedure or function Stored Procedure or Function Name has too many arguments specified.
SQL Server Error Messages - Msg 8144 - Procedure or function Stored Procedure or Function Name has too many arguments specified.

SQL Server Error Messages - Msg 8144

Error Message:

Server: Msg 8144, Level 16, State 2, 
Procedure Stored Procedure or Function Name, Line 0
Procedure or function Stored Procedure or Function Name 
has too many arguments specified.

Causes:

As the message describes, this error is encountered when you are passing arguments or parameters to a function or stored procedure which is more 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) )
RETURNS VARCHAR(20)
AS
BEGIN
    RETURN ISNULL(@pString1 + ' ', '') + ISNULL(@pString2, '')
END

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

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

The error will be encountered you pass more than 2 arguments or parameters to the function, as follows:

SELECT [dbo].[ufn_Concat] ( [FirstName], [MiddleName], [LastName] ) AS [FullName]
FROM [dbo].[Customers]
Server: Msg 8144, Level 16, State 2, Line 1
Procedure or function dbo.ufn_Concat has too many arguments specified.

Solution/Workaround:

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 Topics: