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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 SSIS and Import/Export (2012)
 DT_Numeric Type CAsting error in SSIS
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Constraint Violating Yak Guru

323 Posts

Posted - 08/26/2014 :  15:38:13  Show Profile  Visit pareshmotiwala's Homepage  Click to see pareshmotiwala's MSN Messenger address  Send pareshmotiwala a Yahoo! Message  Reply with Quote
((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?

Paresh Motiwala
Boston, USA

Flowing Fount of Yak Knowledge

2780 Posts

Posted - 08/27/2014 :  08:53:03  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000