SQL - I need to divide a total value into multiple rows in another table
===

Lets say I have the following tables in SQL server 2008

School Table

    School_Id |Course_Id | Total Students | 
    --------------------------------------- 
       1         Acct101        150
       1         Acct102        100
       2         Acct101        110
       2         Acct102        130

Class Table

    School_Id |Course_Id | Class_ID | Capacity
    --------------------------------------- 
       1         Acct101     A1       65
       1         Acct101     A2       50
       1         Acct101     A3       70
       1         Acct102     Ab1      100
       1         Acct102     Ab2      100
       2         Acct101     B1       80
       2         Acct101     B2       90

Based on the given information, I need to display total students per class as follow:

        School_Id |Course_Id | Class_ID | Capacity | Students 
        ------------------------------------------------- 
           1         Acct101      A1        65        60
           1         Acct101      A2        45        40
           1         Acct101      A3        70        50
           1         Acct102      Ab1       100       70
           1         Acct102      Ab2       100       30
           2         Acct101      B1        80        60
           2         Acct101      B2        90        50

I got the students value in the first 3 rows based on the total students value in the first row in school table which is 150

So I divide 150 into 3 classes and took class capacity into consideration while dividing.

How can I acheive this ?

Please Note that I have a table with +500,000 rows and another one with totals summary values, so I need to plug in values in the first table based on the totals summary.