i am converting a varchar type to int..
sum(cast(Replace([ExtraWokedHrs],'Mins','')as int)) as [ExtraWokedHrs]
but i am getting an error...
Msg 245, Level 16, State 1, Procedure PerfomanceReport, Line 544
Conversion failed when converting the varchar value '0 Mins' to data type int.
PLS help
Loading
Manikavelu VelayuthamPosted Nov 10, 2010, 4:55 AM
Suthish NairPosted Nov 10, 2010, 4:49 AM
Natarajamani VenugopalPosted Nov 10, 2010, 4:47 AM
Manikavelu VelayuthamPosted Nov 10, 2010, 4:08 AM
create table test(ExtraWokedHrs vARCHAR(50))
insert into test values ('21Mins')
insert into test values ('22Mins')
insert into test values ('23Mins')
insert into test values ('24Mins')
select sum(cast(Replace(ExtraWokedHrs,'Mins','')as int)) as ExtraWokedHrs from test
ExtraWokedHrs
90
Natarajamani VenugopalPosted Nov 10, 2010, 3:58 AM
Manikavelu VelayuthamPosted Nov 10, 2010, 3:22 AM
How it will convert '0 Mins' to a Integer. 'Mins' is a word.
Only the numerical strings can be converte into Integer variable.
Eg:-
'123' --> can be converted to 123
'12' --> can be converted to 12
'1' --> can be converted to 1