SSIS 2012 - How to specify the number of digits (precision) after the comma

450 views Asked by At

I made an formula in an update statement in order to generate Targets according to a Date_Key. The table 'Test' exists of two relevant columns:

'Date_Key'(INT) and 'Target'(DECIMAL)

The logic I want to implement is as follows:

UPDATE       Test
SET          Target = 175+(2.879546*([Date_Key]-25))

It works but I would like three digits after the comma.

Can someone help me out?

Thank you in advance!

1

There are 1 answers

1
Eric Hauenstein On BEST ANSWER

You need to cast your INT to a more precise format; in your case is should be DECIMAL (X,3).

UPDATE       Test
SET          Planned_Headcount = 175+(2.879546*(CAST([Date_Key] as DECIMAL(X,3))-25))

The "X" above should be a number that large enough to contain the results of your math. 12 would likely suffice, but you would need to test since I have no idea what the value of [Date_Key] might be.

Also, ensure that the decimal column you are trying to update (either "Target" or "Planned Headcount", whichever is correct) also has at least 3 digits of precision, i.e. is DECIMAL(x,3).

This seems like an odd requirement.