my collector current varies according to the load resistance connected
to it.
I should hope so.
Start with Ohm's Law, E = iR. Let's take i as .317 amps, and R as 100 ohms. Then the voltage will be 31.7 volts. Getting 31.7 volts from a 12 volt supply is a pretty good trick.
In fact, with a 10 ohm series resistor, and assuming a Vce of 1 volt or more (since for Vce lower than this the transistor is in saturation and the gain is MUCH less than 100), a 3.17 volt drop on the resistor and a 1 volt drop on the transistor only leave about 7.8 volts available for the load at the desired current. Again applying Ohm's Law says that for any resistance greater than about 24 ohms the current available will be less than the desired .317 and will vary with load resistance.
Other comments apply. Additionally, if the minimum gain of the transistor is 30, and you provide 3.17 mA of base current, by definition your collector current will be 30 x 3.17 mA, or 95 mA, rather than 317. What, exactly, do you mean by a "took the beta as 100 for safety"? Taking the beta as 100 is a) not guaranteed to happen in the real circuit (minimum is 30, right? Do you understand that "minimum" means that there is no guarantee that it will be larger, only that it will not be less?), and b) not going to provide consistent results, since as Andy aka has pointed out, beta varies with current and voltage. Modern data sheets don't go into this much, but in olden days they would typically provide graphs of typical variations.
Please tell me ... how to make the circuit work.
Sorry. Won't happen. You can increase V2 to at least 36 volts, and adjust the base drive with R1 to produce an appropriate current with a specific TIP42 at a specific load resistance, but neither of these things will provide a precision current level independent of load resistance. And also note that, if you do try this, for a load of 50 ohms the TIP42 will dissipate something like 5 watts, and for a 1 ohm load it will be about 10 watts, so unless you provide a decent heat sink (and I don't mean one of those little clip-ons, either) you'll get thermal effects ranging from increased current due to increased leakage to Letting the Magic Smoke Out.
Plus, at a 36 volt supply, you'll be right up against the 35 volt Vds rating of the 2N6659, so increasing R2 would be a very good idea.