FIX: SP_PROCESSMAIL May Fail with Error 18023 (303664)



The information in this article applies to:

  • Microsoft SQL Server 2000 (all editions) SP1

This article was previously published under Q303664
BUG #: 354799 (SHILOH_BUGS)

SYMPTOMS

When you execute the sp_processmail system stored procedure, you may see the following error message:
Server: Msg 18023, Level 16, State 1, Line 0 xp_findnextmsg: An error occurred while setting output value of parameter 1. Check parameter declaration Queries processed: 0.

CAUSE

The length of a mail message ID is 94 characters. However, the @msg_id variable in the sp_processmail stored procedure is declared as varchar(64). The same applies to the @current_msg variable, it has been declared as varchar(64). As a result, the whole message ID string cannot be stored in those variables.

RESOLUTION

To resolve this problem, obtain the latest service pack for Microsoft SQL Server 2000. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

290211 INF: How to Obtain the Latest SQL Server 2000 Service Pack

WORKAROUND

Create a copy of the stored procedure and change the copy by declaring the two variables as varchar(94) like this:
create procedure sp_processmail --- 1996/06/19 17:30
	@subject varchar(255)=NULL,
	@filetype varchar(3)='txt',
	@separator varchar(3)='tab',
	@set_user varchar(132)='guest',
	@dbuse varchar(132)='master'
as

declare @status int
declare @msg_id varchar(94)		-->Change this to varchar(94)
declare @originator varchar(255)
declare @cc_list varchar(255)
declare @msgsubject varchar(255)
declare @query varchar(8000)
declare @messages int
declare @mapifailure int
declare @resultmsg varchar(80)
declare @filename varchar(12)
declare @current_msg varchar(94) 	-->Change this to varchar(94)
...
				
Then, use the newly created user stored procedure to process mail.

STATUS

Microsoft has confirmed this to be a problem in SQL Server 2000 Service Pack 1 (SP1). This problem was first corrected in Microsoft SQL Server 2000 Service Pack 2.

Modification Type:MajorLast Reviewed:10/15/2002
Keywords:kbBug kbDSupport kbSQLServ2000SP2Fix KB303664