遵循T-Sql代码:
DECLARE @usu VARCHAR(10);
SET @usu = 'TOM';
PRINT @usu;
RAISERROR ('Name of USU is %i ',14,2,@usu);
返回以下错误:
Msg 2786,Level 16,State 1,Line 4
替换的数据类型 参数1与格式的预期类型不匹配 说明书
有谁知道如何摆脱这个错误?
答案 0 :(得分:5)
是的,将格式更改为Name of USU is %s
,%i
表示@usu
的值是有符号整数。所有格式类型都明确documented on MSDN。
答案 1 :(得分:4)
尝试改变:
RAISERROR ('Name of USU is %i ',14,2,@usu);
进入那个
RAISERROR ('Name of USU is %s ',14,2,@usu);
因为@usu是varchar(10)而%i表示有符号整数
答案 2 :(得分:1)
试
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);