• Nice code, well layed out & well documented.

    Because max on varchars doesn't work too well (it just works on the ascii value of the 1st character - e.g. '7' is greater than '12888234') maybe #fixeddrives should be declared as follows

    Create table #fixeddrives(

    Drive char(1) null,

    FreeSpace bigint null)

    Nice coding - it saved me a few hours!