Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Error converting data type varchar to float Expand / Collapse
Author
Message
Posted Friday, February 22, 2008 9:21 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, June 4, 2010 2:50 AM
Points: 40, Visits: 85
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.


Post #459172
Posted Friday, February 22, 2008 1:58 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Thursday, October 23, 2008 1:43 PM
Points: 89, Visits: 206

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
Post #459297
Posted Friday, February 22, 2008 2:15 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 7:23 PM
Points: 20,860, Visits: 32,883
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/




Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #459307
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse