![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
How do i conver from varchar to float |
#3
| |||
| |||
|
|
How do i conver from varchar to float |
#4
| |||
| |||
|
|
I have brought the data in from a csv file. Converted the colums to varchar 12. Now i am trying to convert the columns so the that they are numeric. decimal so that i can calulate fields. These fields will be used within a cube. the data looks like the following. Labour Hours varchar 12 and sample data looks like 0.10 rate varchar 12 and sample data looks like 24.30 amount varchar 12 and sample data looks like 2.51 I keep getting a error when trying to convert. I have tried declaring a variable but this failed. ----- Allan Mitchell wrote: ----- What does your varchar value look like ? declare @v varchar(10) set @v = '123.4324' select CAST(@v as float) -- ---------------------------- Allan Mitchell (Microsoft SQL Server MVP) MCSE,MCDBA www.SQLDTS.com I support PASS - the definitive, global community for SQL Server professionals - http://www.sqlpass.org "shane" <anonymous (AT) discussions (DOT) microsoft.com> wrote in message news:4D6234BD-2A12-4D7C-88C1-04FE5A6060E0 (AT) microsoft (DOT) com... How do i conver from varchar to float |
#5
| |||
| |||
|
#6
| |||
| |||
|
|
I created the table like you said and did a insert into. I then tried to convert data but it failed. What other steps can i use to clean this data and then convert to the required format. |
#7
| |||
| |||
|
#8
| |||
| |||
|
|
I will start from the beginning , i import data into a table from a csv file. From there i have convert the data to varchar 12 and imported into stg table 2 from here i am trying to convert the data into numeric or decimal |
#9
| |||
| |||
|
#10
| |||
| |||
|
|
Allen thanks for your help with this 1. I have located the problem. It starts at the source. Some of the fields have spaces in the cells. This is |
|
cheers, |
![]() |
| Thread Tools | |
| Display Modes | |
| |