For most technical questions in the database space, there are several things you can do to get the best and quickest answers from the largest number of people. The most succinct advice I've seen is in the help center for Database Administrators Stack Exchange:
To get even more TL;DR: The easiest way I've found to quickly set up a question for SQL Server is to use db<>fiddle. Create a representative table, enough sample data to cover edge cases, desired results, and the query you've tried that doesn't work.
Don't post screenshots (or photographs of your screen). Background here. People need actual CREATE TABLE
and INSERT
statements (best provided in a fiddle) to get right down to solving your problem. If they have to spend any effort creating a table and building sample data, they're more likely to just move on to the next question.
Don't reprimand people for providing feedback on parts of your design or code that may or not be related to the specific problem you have right now. All you're doing is discouraging them from participating further, and that only hurts you. If parts of your code aren't relevant to the problem, don't include them. We don't need 15 outer joins to evaluate why ORDER BY
isn't working as you expect.
A complicated part of asking a good question is finding the right balance of providing enough information but not too much. Be careful not to over-simplify, because people will have to ask you prodding questions to get enough information to solve the problem (and in the meantime others may have already tried to solve a now different problem – we call these "chameleon questions"). On the other hand, the word "minimal" up there is first for a reason – sometimes people will post 800 lines of T-SQL when 5 would have been enough.
I have some further advice that gets into more of the nitty-gritty, though it is admittedly SQL Server-centric:
Erik Darling, the nicest former bouncer I know, has some great content here:
Gianluca Sartori has this great post:
Stack Overflow has its own version, but it is less focused on database problems specifically:
Eric Raymond and Rick Moen updated their long-standing article with a specific section on Stack Overflow:
Though there is also this Stack Overflow tag wiki that focuses on query optimization problems specifically:
There's also this great meta question:
And this great post from Tomáš Zíka about not being lazy:
And this rant from Eric Lippert explaining why "which is faster?" questions are bad news:
And finally, Jon Skeet has multiple blog posts discussing the science of a Q & A community, and they are well worth a read, whether you ask questions, answer them, or both:
I am a passionate technologist with industry experience dating back to Classic ASP and SQL Server 6.5. I am a long-time Microsoft MVP, write at Simple Talk, SQLPerformance, and MSSQLTips, and have had the honor of speaking at more conferences than I can remember. In non-tech life, I am a husband, a father of two, a huge hockey and football fan, and my pronouns are he/him.