SQL integration Services Data Type Issue

In an Execute SQL Task control Flow I am using the Single Row Result Set. SQL Query follows: Select Count(*) As Rec_Ct, Sum(Value) As Tot_Val From Sales_Table. The Rec_Ct field is assigned to the RecordCount(int32) variable and the Tot_Val(numeric(16,5) is assigned to the TotalValue(double) variable. Upon execution I receive the error "The type of the value being assigned to variable TotalValue differs from the current type". I have run this package without the Sum(Value) field and the package runs fine. Is it possible to use the SUM aggregate in Integration Services ? Is there another variable type I should be using ? Thanks.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

The definition of the sum() function (here) indicates that for a decimal parameter it returns decimal(38, s).

Therefore, looking at the definitions of SSIS data types (here) I would suggest that you use either DT_NUMERIC or DT_DECIMAL. DT_NUMERIC is the larger and so may be necessary for you.


StampITAuthor Commented:
When configuring a variable neither DT_DECIMAL nor DT_NUMERIC are options under Data Type. Boolean, Byte, Char, Dattime,Dbnull,Double,Int16, Int32, Int64, Object, SByte, Single, String, UInt32, and Uint64 are the options. I have tried Double and Single. Tried to convert into varchar and use Char for the variable. None of this worked. Thanks.
You missed the Decimal - it's the one above the Double. .........
Oh! oops! I'm very sorry! I just noticed that your message is tagged SQL Server 2008.

Please use an Object until you get SQL Server 2012, when Decimal is introduced. There's a translation map here that you may find useful.

Again, my apologies!


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

StampITAuthor Commented:
Presumably that helped! Good.
StampITAuthor Commented:
Yes. Using the Object data type for the variable allowed storage of the query result. Thanks.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.