BUG: Raiserror with %i Type Displays Incorrect Integer Value (296637)



The information in this article applies to:

  • Microsoft SQL Server 7.0

This article was previously published under Q296637
BUG #: 58282 (SQLBUG_70)
BUG #: 101143 (SQLBUG_70)

SYMPTOMS

The msg_str parameter in the Raiserror function can include a %i type specification to represent a signed integer value. This type specification does not return the correct value.

For example, the following statement:
Raiserror ('Database has not been dumped in %i hours.',16,2,123)
				
returns a message that resembles the following (the actual number returned will vary):
Server: Msg 50000, Level 16, State 2, Line 1
Database has not been dumped in 805895076 hours.
Raiserror used with sp_addmessage behaves in the same way; for example, the following code:
sp_addmessage 50005, 16,
	'Database has not been dumped in %i hours.'
go
Raiserror (50005, 16, 1, 123)
				
returns a message like this (again, the number will vary):
Server: Msg 50005, Level 16, State 1, Line 1
Database has not been dumped in 805895076 hours.

WORKAROUND

Use the %d (signed integer) or %u (unsigned integer) type specification instead.

STATUS

Microsoft has confirmed this to be a problem in SQL Server 7.0.

Modification Type:MajorLast Reviewed:9/4/2002
Keywords:kbbug KB296637