RAISERROR raises substitution parameter error
11,876
Solution 1
Yeah, change your format to Name of USU is %s
, the %i
means the value of @usu
is a signed integer. All of the format types are clearly documented on MSDN.
Solution 2
Try to change that:
RAISERROR ('Name of USU is %i ',14,2,@usu);
into that
RAISERROR ('Name of USU is %s ',14,2,@usu);
since @usu is varchar(10) and %i means signed integer
Solution 3
try
DECLARE @usu VARCHAR(10);
SET @usu = 'TOM';
PRINT @usu;
--modify this line RAISERROR ('Name of USU is %i',14,2,@usu);
RAISERROR ('Name of USU is %s',14,2,@usu);
http://msdn.microsoft.com/en-us/library/ms178592.aspx
Related videos on Youtube
Author by
Tom Stevens
Updated on July 12, 2022Comments
-
Tom Stevens almost 2 years
following T-Sql code:
DECLARE @usu VARCHAR(10); SET @usu = 'TOM'; PRINT @usu; RAISERROR ('Name of USU is %i ',14,2,@usu);
returns following error:
Msg 2786, Level 16, State 1, Line 4
The data type of substitution parameter 1 does not match the expected type of the format specification.Does anyone know how I can get rid of this error?
-
Kermit over 10 yearsI would stop doing what the error message is hinting at.
-