Click here to Skip to main content
16,008,954 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
@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.
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?
Posted
Updated 4-Oct-11 2:02am
v3
Comments
André Kraak 4-Oct-11 7:14am    
Edited question:
Added pre tags
Formatted text/code
Spelling/Grammar

1 solution

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.
 
Share this answer
 
Comments
RoshInd 4-Oct-11 7:46am    
its correct,
Ans_ID=AD.ADD_Answers ,here i assigned the varchar value to int.
Thaks a lot.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900