当执行存储过程时,会出现如下错误:将varchar值'True'转换为int时转换失败. [英] when executing the stored procedure an error comes like this:conversion failed when cionverting the varchar value 'True' to int.

查看:179
本文介绍了当执行存储过程时,会出现如下错误:将varchar值'True'转换为int时转换失败.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

@strMode as varchar(2),
@TMID as int=null,
@UsersID as int=null,
@ClassID as int=null, 
@AAID as int=null 

if(@strMode='MA')
begin
	select A.Que_ID,A.Ans_ID,A.Ans_Answer,A.Ans_FileName,(select Ans_Answer from Answer where Ans_ID=cast(AD.ADD_Answers as int)and Q.Que_Type=3 and(AD.ADD_Answers<>'true' or AD.ADD_Answers<>'false')) as studentanswer,Q.Que_Type,Q.Que_Group,TD.TS_ID
	from ActivityDoneDetails AD inner join TestDetails TD on TD.Que_ID=AD.Que_ID and AD.AA_ID=@AAID and AD.Users_ID=@UsersID
				left outer join Question Q on TD.Que_ID=Q.Que_ID 
				left outer join Answer A on Q.Que_Id=A.Que_ID                 
	where TD.TM_ID=@TMID and (Q.Que_Type=3) and Q.Que_IsDeleted=0
end

When executing the stored procedure an error comes like this:<pre lang="text">conversion failed when converting the varchar value 'True' to int.

一直没有显示错误当执行SP时.有时它工作正常.
我已经将其转换为:Ans_ID = cast(AD.ADD_Answers as int)
然后也会出现相同的错误.

有人可以帮我吗?

Its not showing the error all the time when the SP is executed. Sometimes it is working fine.
I have converted this: Ans_ID=cast(AD.ADD_Answers as int)
then also the same error comes.

Could anyone help me?

推荐答案

很难说问题出在哪里,因为您没有提供列类型.

但是SQL却说您的varchar列之一是一个数字值,但是您有一个"True"字符串.

检查您的行,看看这在哪里.如果值与预期的数据类型不匹配,则可能需要重新考虑您的查询.
It''s hard to say where the problem is exactly as you have not given the column types.

But SQL is saying that one of your varchar column you were expecting a numeric value but you have a ''True'' string.

Check your rows and see where this is. You may need to rethink your query if the values don''t match in expected data type.


这篇关于当执行存储过程时,会出现如下错误:将varchar值'True'转换为int时转换失败.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆