June 14, 2013 at 10:08 pm
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?
June 14, 2013 at 10:43 pm
12.00 is not an integer. so you can convert this value to an int.
if it is 12 then you can do it.:hehe:
June 14, 2013 at 10:49 pm
yes i know that.but i need '12.00' as result.so what should i change here?
June 14, 2013 at 11:38 pm
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
June 14, 2013 at 11:40 pm
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.
June 15, 2013 at 12:22 am
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)
June 15, 2013 at 12:41 am
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 .
June 15, 2013 at 1:03 am
thank u sir.i got it
Viewing 8 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy