Microsoft KB Archive/313408

= BUG: The Xp_logevent Stored Procedure Truncates Messages to 256 Characters =

Article ID: 313408

Article Last Modified on 12/3/2003

-

APPLIES TO


 * Microsoft SQL Server 2000 Standard Edition
 * Microsoft SQL Server 7.0 Standard Edition
 * Microsoft SQL Server 7.0 Service Pack 1
 * Microsoft SQL Server 7.0 Service Pack 2
 * Microsoft SQL Server 7.0 Service Pack 3
 * Microsoft SQL Server 7.0 Service Pack 4

-



This article was previously published under Q313408



BUG #: 355409 (SHILOH_BUGS)

BUG #: 102028 (SQLBUG_70)



SYMPTOMS
You can use the xp_logevent extended stored procedure to log user-defined messages in the SQL Server Errorlog file and in Event Viewer files.

In Microsoft SQL Server Books Online, it states that the xp_logevent extended stored procedure can manage messages that include up to 8000 characters; however, the xp_logevent extended stored procedure truncates messages that are longer than 256 characters.



CAUSE
This problem occurs because the SQL Server code for the extended procedure xp_logevent incorrectly copies the input string into a variable of 256 characters, which causes the truncation in the message.



WORKAROUND
To generate an error message in which the text size exceeds 256 characters, use one of the following workarounds:   Add a user-defined message by using the sp_addmessage stored procedure. Set @with_log to TRUE, and then use RAISERROR to log the message in the SQL Server Errorlog file.

The following sample Transact-SQL code demonstrates how you can use RAISERROR: USE master EXEC sp_addmessage @msgnum = 99999, @severity = 10, @msgtext = N'This is a test message', @lang = 'us_english', @with_log = true go raiserror ( 99999, 10 , 1) -Or-  Log multiple smaller messages by using the xp_logevent stored procedure when you need to log text that exceeds 256 characters in the SQL Server Errorlog file.



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

Keywords: kbbug kbpending KB313408

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.