Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Conversion failed when converting the varchar value '12.00' to data type int.


Conversion failed when converting the varchar value '12.00' to data type int.

Author
Message
neethu payal
neethu payal
Valued Member
Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)

Group: General Forum Members
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?
Mr. Kapsicum
Mr. Kapsicum
Right there with Babe
Right there with Babe (748 reputation)Right there with Babe (748 reputation)Right there with Babe (748 reputation)Right there with Babe (748 reputation)Right there with Babe (748 reputation)Right there with Babe (748 reputation)Right there with Babe (748 reputation)Right there with Babe (748 reputation)

Group: General Forum Members
Points: 748 Visits: 973
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
neethu payal
neethu payal
Valued Member
Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)

Group: General Forum Members
Points: 63 Visits: 94
yes i know that.but i need '12.00' as result.so what should i change here?
Mr. Kapsicum
Mr. Kapsicum
Right there with Babe
Right there with Babe (748 reputation)Right there with Babe (748 reputation)Right there with Babe (748 reputation)Right there with Babe (748 reputation)Right there with Babe (748 reputation)Right there with Babe (748 reputation)Right there with Babe (748 reputation)Right there with Babe (748 reputation)

Group: General Forum Members
Points: 748 Visits: 973
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
Mr. Kapsicum
Mr. Kapsicum
Right there with Babe
Right there with Babe (748 reputation)Right there with Babe (748 reputation)Right there with Babe (748 reputation)Right there with Babe (748 reputation)Right there with Babe (748 reputation)Right there with Babe (748 reputation)Right there with Babe (748 reputation)Right there with Babe (748 reputation)

Group: General Forum Members
Points: 748 Visits: 973
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.
neethu payal
neethu payal
Valued Member
Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)

Group: General Forum Members
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)
Mr. Kapsicum
Mr. Kapsicum
Right there with Babe
Right there with Babe (748 reputation)Right there with Babe (748 reputation)Right there with Babe (748 reputation)Right there with Babe (748 reputation)Right there with Babe (748 reputation)Right there with Babe (748 reputation)Right there with Babe (748 reputation)Right there with Babe (748 reputation)

Group: General Forum Members
Points: 748 Visits: 973
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 .
neethu payal
neethu payal
Valued Member
Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)

Group: General Forum Members
Points: 63 Visits: 94
thank u sir.i got it
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search