Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Conversion failed when converting the varchar value '12.00' to data type int. Expand / Collapse
Author
Message
Posted Friday, June 14, 2013 10:08 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Saturday, December 6, 2014 5:33 AM
Points: 63, Visits: 94
DECLARE @mv_mark varchar(500),
@ob_mark varchar(500),
@tot varchar(500),
@mv_mark1 varchar(500),
@ob_mark1 varchar(500)


SELECT @mv_mark =mv_mark
FROM internal_nontheory_mark
WHERE roll_no = '11csu002' AND regulation_sub_id = 15849

SELECT @ob_mark = ob_mark
FROM internal_nontheory_mark
WHERE roll_no = '11csu002' AND regulation_sub_id = 15849

SET @mv_mark1 = CAST(COALESCE(@mv_mark, 0) AS VARCHAR)

SET @ob_mark1 = CAST(COALESCE(@ob_mark, 0) AS VARCHAR)

select @mv_mark1,@ob_mark1

when i execute it returns 'Conversion failed when converting the varchar value '0.00' to data type int.
what should i do?
can anyone help me?
Post #1463811
Posted Friday, June 14, 2013 10:43 PM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Monday, December 15, 2014 10:57 PM
Points: 517, Visits: 646
12.00 is not an integer. so you can convert this value to an int.
if it is 12 then you can do it.

Post #1463813
Posted Friday, June 14, 2013 10:49 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Saturday, December 6, 2014 5:33 AM
Points: 63, Visits: 94
yes i know that.but i need '12.00' as result.so what should i change here?
Post #1463814
Posted Friday, June 14, 2013 11:38 PM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Monday, December 15, 2014 10:57 PM
Points: 517, Visits: 646

DECLARE @mv_mark varchar(500),
@ob_mark varchar(500),
@tot varchar(500),
@mv_mark1 varchar(500),
@ob_mark1 varchar(500)


SELECT @mv_mark =mv_mark
FROM internal_nontheory_mark
WHERE roll_no = '11csu002' AND regulation_sub_id = 15849

SELECT @ob_mark = ob_mark
FROM internal_nontheory_mark
WHERE roll_no = '11csu002' AND regulation_sub_id = 15849

SET @mv_mark1 = CAST(COALESCE(@mv_mark, '0') AS VARCHAR)

SET @ob_mark1 = CAST(COALESCE(@ob_mark, '0') AS VARCHAR)

select @mv_mark1,@ob_mark1
Post #1463818
Posted Friday, June 14, 2013 11:40 PM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Monday, December 15, 2014 10:57 PM
Points: 517, Visits: 646
Mr. Kapsicum (6/14/2013)

DECLARE @mv_mark varchar(500),
@ob_mark varchar(500),
@tot varchar(500),
@mv_mark1 varchar(500),
@ob_mark1 varchar(500)


SELECT @mv_mark =mv_mark
FROM internal_nontheory_mark
WHERE roll_no = '11csu002' AND regulation_sub_id = 15849

SELECT @ob_mark = ob_mark
FROM internal_nontheory_mark
WHERE roll_no = '11csu002' AND regulation_sub_id = 15849

SET @mv_mark1 = CAST(COALESCE(@mv_mark, '0') AS VARCHAR)

SET @ob_mark1 = CAST(COALESCE(@ob_mark, '0') AS VARCHAR)

select @mv_mark1,@ob_mark1







Check if this helps.
your coalesce is giving you problem here. have handled your varchar and int conversion by making your 0 in coalesce as varchar.
Post #1463819
Posted Saturday, June 15, 2013 12:22 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Saturday, December 6, 2014 5:33 AM
Points: 63, Visits: 94
thank you very much sir...it works well .and i have to sum both the values so i tried this but the same problem?
SET @total = CAST(( CAST(ISNULL(@mv_mark, 0) AS INT) + CAST(ISNULL(@ob_mark, 0) AS INT)) AS VARCHAR)
Post #1463822
Posted Saturday, June 15, 2013 12:41 AM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Monday, December 15, 2014 10:57 PM
Points: 517, Visits: 646
what you are trying to do here is to add a varchar value to int value. which is not possible.

think a little bit more logical. if you dont get the answer, will surely help you then .
Post #1463825
Posted Saturday, June 15, 2013 1:03 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Saturday, December 6, 2014 5:33 AM
Points: 63, Visits: 94
thank u sir.i got it
Post #1463828
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse