Little help?

I have a long text field in a database which I need to split after 40 charaters at the next space.

e.g
from this:
This is a long text field

to this:
this is a long
text field

not this:
this is a long te
xt field

anyone any ideas??

Thanks