0

I'm trying to convert a varchar to a float and getting the following message.

Msg 8114, Level 16, State 5, Line 41
Error converting data type varchar to float. The statement has been terminated.

This is what I tried.

ALTER TABLE All_Active
ALTER COLUMN [BE #] float

Please tell me there is an easy solution for this. This should be float. It imported into SQL Server incorrectly.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
ASH
  • 20,759
  • 19
  • 87
  • 200
  • You probably have a value in that table & column that cannot be converted to float. Did you check that? – Mark PM Jul 23 '16 at 21:04

1 Answers1

1

You have a value that is not a valid floating point value. If you want to alter the column, then first update date it remove such values:

update all_active
    set [BE #] = (case when isnumeric([BE #]) = 1 then [BE #] end);

Then update the alter table:

ALTER TABLE All_Active ALTER COLUMN [BE #] float
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
  • I re-imported the file as Excel, instead of CSV, and everything is fine now. Thanks everyone. It's Saturday and it's sunny out! Time to stop working!!! – ASH Jul 23 '16 at 21:15