Error converting data type varchar to float

  • Is there an easy or best way of overcoming the following error (as messaged):

    Error converting data type varchar to float.

    It is resulting from a INSERT statement by the way.

    I've tried :

    SELECT [Col001], [Col002], [Col003], cast([Col004] AS FLOAT), cast([Col005] AS FLOAT), CAST([Col006] AS FLOAT), CAST([Col007] AS FLOAT) FROM [Base_tables_Correlations_B].[dbo].[Result_Males_and_Females_DSRs] WHERE Col005 IS NOT NULL

    Also I've used the Convert function without luck.

  • [font="Arial"]

    Hello,

    I tried the following using the explicit conversion.

    declare @firstNumber float,

    @nbrString varchar(10)

    set @nbrString = '123.45'

    select @firstNumber = @nbrString

    select @firstNumber

    Result:

    -----------------------------------------------------

    123.45

    (1 row(s) affected)

    Maybe I'm missing something in your question...?

    Please advise.

    Thanks,

    Terry

    [/font]

  • It would help if you could provide us with some sample data. This article will help you put together wjat we need to help you better:

    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    😎

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

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