I can do this in MS-Access (and it works) but need the equivalent in SQL Server 2000. All fields reside in the same table (tbl_Toll_Free_Final). Percent_Busy is a Decimal (18,5) and the others are Integers.
I have tried this and Percent_Busy is updated to 0. Total_Busy_Calls or Overflow_Calls can be 0 so perhaps its a div by zero error but SQL server does not report any error.
UPDATE dbo.tbl_Toll_Free_Final
SET Percent_Busy =
(Total_Busy_Calls + Overflow_Calls) / (Total_Calls + Overflow_Calls)
For example:
- Total_Busy_Calls = 12, Overflow_Calls = 0 so first result is 12
- Total_Calls = 1000, Overflow_Calls = 12 so second result is 1012
- Calculation is 12/1012=0.0119
Hope you SQL Server gurus can help.
Try this:
You are dividing an integer by an integer which ignores decimals, remainders, fractions, etc. By casting the divisor to a decimal, you avoid this integer division.