SQL SSIS/TSQL convert table column from varchar to numeric?

Hello,

I have a table that stores all of my columns as "varchar(150)".

Some of the columns in the table only contain money values and I would like to convert them to such (numeric datatype is best for money?).

Here is how the table looks like:

table-varchar.JPG
The table has about 1.6m rows, how can I using TSQL or SSIS efficiently convert the three columns from varchar to a more appropriate datatype for money?

Please let me know, I am looking for a descriptive example of how to make this work.

Thanks.
mirdeAsked:
Who is Participating?
 
Patrick MatthewsCommented:
Actually, IMHO the best data type to use for money is...the money data type!  (Yes, there is one.)

Anyway...

SELECT CONVERT(money, LTRIM(RTRIM([TF FOB]))) AS [TF FOB]
FROM SomeTable
WHERE ISNUMERIC(LTRIM(RTRIM([TF FOB]))) = 1

Open in new window

0
 
mirdeAuthor Commented:
Thanks that worked.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.