August 4, 2010 at 2:41 pm
Hi
Yes,working with CSV files is really hard. Lot of manual formating has to be done.
SELECT CAST ('6.68E+07' AS FLOAT)
Do I have to do this for every such value? I have a lot of these.
How would this be included into my above query?
Thanks
August 4, 2010 at 2:55 pm
you don't need to do that for all manually, use an update statement.. to update all values with 'E' in it using a case statement with Patindex
August 4, 2010 at 3:05 pm
Hi
Divyanth,Can you update my query with what you are saying ?
Thanks
August 5, 2010 at 7:44 am
I would suggest using a SELECT that CELKO suggests as updating is always expensive..But if you still want to below is the code
UPDATE TableName
SET ColName = CAST (CAST(ColName AS FLOAT) AS DECIMAL(15,8))
WHERE PATINDEX('%E%',ColName) <> 0
August 5, 2010 at 11:52 am
Hi,
Thankyou guys, great help.
@CELKO .... I can't BULK INSERT from a CSV file into the table if I use the right datatypes. So I have to do all the manipulations in Views. I can only import data if I use VARCHAR. Also for now I don't want to use any ETL tools.
@divyanth .... Thanks for the query .... but CELKO's query works for me as I don't want to change the table coz if I do, I would not be able to insert more data into the table from other CSV files.
Thanks.
Viewing 5 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply