My boss (and, actually, his boss too, which is the company general director) are generally quite good.
But it happens (seldom, but frequently enough) that they start to fiddle with the details: day to day chores that they should not do.

Examples are: DB queries to extract data, scripts to parse excel files, even re-installing software on their workstation, and the like. The problem is that there are people in the company that could do it much better, much faster. Often, we already have programs or libraries to do what they are trying to do in a more efficient way, or we can create them. 

This is not a very urgent problem, per-se (even if they make mistakes - not being their primary job, they may miss or forget important points), but that eats up their time, and that's the real issue: he does have very little time to "manage" (listen to his subordinates, make decisions, planning...)

How can I convince them to stop "doing", without being rude, annoying, or worse?
(he is still my boss, after all :) )
I know that for some people giving up the "getting my hands dirty" is difficult, but I really feel this is becoming a problem and I want to try to improve the situation.

---

EDIT:
Just to clarify: him doing things is both a problem by itself (but that is specific to my case, so I won't bother you with this part), and above all, a problem because it hinders his ability to manage others. Getting an answer by email is very difficult, meet him 1-1 to discuss projects, software to buy, planning, requires days or weeks, etc.

I am a team leader myself, and I strongly believe in leading by example, which means also working with your colleagues, but my first obligation with my people is to lead them, otherwise I may end up blocking 10 developers because they are waiting for an answer from me.
['https://workplace.stackexchange.com/questions/42335', 'https://workplace.stackexchange.com', 'https://workplace.stackexchange.com/users/7408/']
I'm kind of latching on to one idea that may not actually be relevant, but one thing you mentioned was the difficulty of giving up "getting my hands dirty". This could be true, or it could be that he just fails at delegating tasks once in a while. Various reasons could be at play for not delegating:

* He's uncomfortable with delegating tasks(or otherwise hasn't gotten used to it yet)
* The tasks he ends up doing are close to his experience, so he sees himself as the obvious candidate
* He really does like getting his hands dirty.
* Doing those tasks reminds him of what he's passionate about.
* He wants a break from his other duties.
* Etc. He certainly isn't the first person to move up and miss doing the grunt work.

If you end up in meetings where your boss says things like "Today I'm going to try doing `<drone work tasks>` to help you guys along", then whoever has the most experience with those drone tasks could speak up and ask to do them instead. 'Ask' is the key word in the last sentence. Don't *tell* your boss you're going to do the task - *ask* him. It's important that he sees he has the power to make the decision. Eg. (You say) "Oh! I've been working on the SQL queries lately and have a few scripts that help me. I could do `<the thing>` and have the report in your e-mail by close-of-business today. Would that be ok with you?" 

The key is to make it really easy for him to say 'yes' to you - stack the odds in your favor however you can(you're not busy, it'll take you no time at all, you have the tools ready to go, you won't miss your deadline(s) for anything, his time is better spent elsewhere, etc).

By taking initiative to do these tasks, you(as a team) show him you're willing to step up for him to get the job done, and it's a way of easing him into delegating tasks to people. He may be good at delegating big-picture stuff. He's not stupid enough to think he can do all the work himself. But these one-off situations are trickier, especially when you remember being able to do these kinds of things in a few hours.

**Personal anecdote(I've made my point by now, the rest is fluff):** 

I'm a very non-confrontational person and I'm also a junior software developer. I was given the reins of one of our R&D labs, which may sound more grandiose than it really was - I 'managed' 2 people's time in the lab(both working part time usually, sometimes full time) for roughly 4 months. 

At the start most of my time, roughly 80% weekly, was on my main project, so I had ~8 hours per week (2 hours per day Mon-Thurs) to deal with the R&D lab. I wasn't comfortable with telling people what to do, but I really had no other choice. If I hadn't been thrown in the deep end and had to 'figure it out' so abruptly with the time constraints that I had, I think the transition would've been tougher and I'd be more prone to helping with tasks. To say the least, it was *very* difficult to not stick my hands in the code.

It also helped that the people I 'managed' were two coworkers I had worked with extensively who were both smart and trustworthy. When I gave them tasks, I was certain they'd ask questions if they got stuck, but otherwise they would finish them and not waste time.

Your post doesn't give too much detail, but the delegation thing just got stuck in my head since I went through that last year. If your boss is a newly-made/recently-promoted boss, perhaps that's what he's going through.
EDIT: this answer as written when OP's original version implied they were an individual contributor, before the crucial detail that they are a manager managing a team of 10, which completely changes the question.
Moreover this makes the boss a level-2 manager, which is a different situation.

---

I'd bloody rejoice.

A manager who wants to keep their hand in the game? Consider yourself lucky. This is a blessing in disguise.

I don't see that this a problem, certainly no more than a manager who spends too much time in meetings, presentations, reviews, conferences, executive lunches, politicking, MBA classes, playing golf, drinking, betting on the horses or other sanctioned modes of slacking.

Even if we conclude it's a problem, it's at most a small problem and it's certainly not ***your*** problem.
One good side-effect is that they will still be competent at hiring good technical people, which is something that PowerPoint warriors lose (or delegate to the HR dept, or stop caring, and the organizational rot sets in).

(**What's their motivation?** Need to present credible data to higher-ups? Want to stay technical and deny the cloak of management being thrust upon them? Technically insecure? Impostor syndrome? Afraid of being laid off, or that their role has become obsolete? Want to understand what you or their subordinates are doing better? Want to know how to hire or manage you better? or hire your replacement if you leave? They may have several of these motivations, and don't expect them to tell you.)
Most of those are fine, and even the ones that aren't can work to your advantage.

***You can (privately) show them you that you can do their work faster*** (or some automated script, or query tool, or GUI).
Implement it yourself. If they're a chart person, give them charts. If they're a KPI person, give them numbers. If they like doing it interactively, install a query tool and write a wiki of frequently-used queries. If they want to tie things to the build/SCM process, implement that.
Consider this a hidden opportunity to both do something productive and "get recognition" at multiple levels of the hierarchy.
This is how useful internal tools generally happen. Show them a functional prototype then see if they approve spending further time on it.
a

> 
> I know that for some people giving up the "getting my hands dirty" is difficult
> 
> 
> 

Honestly that's a badge of being a good engineer, if somewhat unrealistic about their productivity. (Read about *"Engineer-not-Manager"*)

> 
> How can I convince them to stop "doing", without being rude, annoying, or worse? 
> 
> 
> 

**It's not your %#@& job to.** If you must, be very oblique. Just offer them a higher-productivity alternative, and privately walk them through it, only if they show interest. Then if they still insist on doing it themselves, then let it be.
They may have some unresolved identity or competence crisis; if so, don't force it.

> 
> but I really feel this is becoming a problem and I want to try to improve the situation.
> 
> 
> 

But it's not, based on anything you've said! Anyway it's not your perception that matters as to whether it's a problem. Don't let your ego be threatened, don't feel insecure.

***tl;dr: Rejoice, let it go, use it to your career advantage, keep them happy while nudging them towards a mutually useful point, boost their managerial self-esteem***