i have a field called measurement filed that has numeric data in it. I am trying to convert measurement from varchar to int but i want a sum of measurement from my table called WOTask.
you can use CONVERT() or CAST() to convert from varchar to int.
Are you facing any issue doing that ? Any error message and sample data for us to better understand your problem
Measurement is a column in my WOTASK table with numeric values in it.
I keep getting an error message
Conversion failed when converting the varchar value to data type int.
CONVERT (int, fieldname)
please send me the table with table structure.
or use another approach, suppose if you have number and character field in one column then use below code.
CASE WHEN ColumnField LIKE '%[^0-9]%' THEN NULL ELSE CONVERT (int , ColumnField) END
Is above my query not work with you?
no that query did not work receiving error message
Your image is cutting off part of the data. Post DDL for the table and inserts for sample rows.
what was the error.
You can please send me the script and data through insert query.
Hello I am trying to do the following:
select sum(measurement) from wotask when doing this i receive the following error message "Operand data type varchar is invalid for sum operator" I have tried the convert, case, ect and receive the same error message. Measurement is (varchar(50),null) and has numeric data
dear send me proper query and table structure
To use SUM you will need to convert (or cast) the VARCHAR to a numeric before the SUM.
Yes your right, but i'm asking you is send me the table structure like create table and columns
and your insert query so i will test and send you with result.