Ecclesiastes 2:21

New American Standard Bible (NASB)
When there is a man who has labored with wisdom, knowledge and skill, then he gives his [p]legacy to one who has not labored with them. This too is vanity and a great evil.

Read Ecclesiastes 2:21 in other translations