Error converting Varchar to Float

  • Hi All,

    I am trying to use the query below but receive the error message

    "Msg 8114, Level 16, State 5, Line 1

    Error converting data type varchar to float."

    Query :

    select w.casecode,w.category,w.desc1,w.weightage,w.WACC,w.Goal_Weighing,f.Factor

    from [dbo].[Final] as w inner join

    [dbo].[Final01] as f

    on w.casecode = f.casecode

    I am surprised because this query is used to create a view. This view was not giving me any error message since last 1 week but suddenly today I pressed button to see results of this view and received this error message. Please help!

  • not sure which of the two tables are the problem, but i'd start by looking at any values that cannot convert to a numeric datatype:

    SELECT * from [dbo].[Final] WHERE ISNUMERIC(casecode) =0

    SELECT * from [dbo].[Final01] WHERE ISNUMERIC(casecode) =0

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Just to add to what Lowell said, float has a higher data type precedence than varchar so when you compare, or join as you are doing, two columns with different data types one column's data must be implicitly converted to the other type so they can be compared. In your query, it is very likely that one of the two columns, the one that is a varchar, has data that cannot be converted to float.

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply