Friday, March 30, 2012

Question relating Conversion and calculations

Hi,

I have couple of DBF files.. and when i get them into my scrub database the datatype for all the fields in char. but after i scrub the data i put them into a money feild.. so that if so that i can do any calculations that i want in the report...

Suppose if i keep as a char or varchar in my production database... is it possible to any calculation on it in my report.. just simple additions... and if yes... do i need to convert them into anything before doing the additions... The reason i am asking this is Some of the fields in the scrub database are empty and i want to keep them the same in my production database instead of showing 0.00 as a default.

Any help will be appreciated.

Regards

Karen

Hi,

From your description, it seems that you want make calculation on fields such as char typed in your database, right?

If so, I think you can achieve it by converting your fields in your stored procedure or select statement.
See the following sample, suppose we have two fields called Sp and Hd, which is nvarchar typed, now we can convert them into money typed and make calculation on them.

selectsum(convert(money,Hd))+sum(convert(money,Sp))As Totalfrom MatrixCapital

Thanks.

No comments:

Post a Comment