Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 SSIS and Import/Export (2012)
 DT_Numeric Type CAsting error in SSIS

Author  Topic 

pareshmotiwala
Constraint Violating Yak Guru

323 Posts

Posted - 2014-08-26 : 15:38:13
((DT_NUMERIC,7,0)REPLACE(["Aggregate Total Space"]," TB","")) * 1024

Friends I have a colum "aggregate total space" that comes in as a varchar(50).
The values have word " TB" or " GB" or " MB" in them.

I am trying to remove these words, and convert this into a numeric value for reporting.
The default is GB. So if the data comes in as TB I multiply the result by 1024. if it comes in as MB then I divide it by 1024. If it comes in as a GB i just convert it and let it pass.

When I run this command I get the following error.
[Removing Reference for " GB" [108]] Error: An error occurred while attempting to perform a type cast.

Can somebody help me?
Cheers
Paresh


Regards
Paresh Motiwala
Boston, USA

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-08-27 : 08:53:03
Don't quote the column name inside the brackets. This works for me


((DT_NUMERIC,7,0)REPLACE([Aggregate Total Space]," TB","")) * 1024


which ran without error.
Go to Top of Page
   

- Advertisement -