How to ask for programming help

Over the past 25 years, I have answered a lot of programming questions in online forums, from co-workers, and from friends. It has been a while since I had been around forums, but I recently decided it was time to get back to what started me in the SQL community: answering questions. Not only is it complementary to my current job as Simple-Talk editor, it is really a great joy to be able to help other people with their problems. It is also educational to see the kinds of things other people are going through before you also go through them.

Sometimes you know the answer right away, but sometimes the question is a challenge (these are actually my favorite.) At times I have spent hours on a question, trying to figure out a solution that works, and then writing up the answer to post back. Along the way I am learning something new and (assuming I figured out a correct answer,) the question poster usually learns something too. I mean, I have been wrong a few times, at least.

Note: One of the reasons it was my starting point in the community was the lack of pressure. You are not the only one answering questions, and if you get it wrong, typically someone will tell you as you will for others. The pressure to be right every time or answer every question is rarely overwhelming/

However, there is one main issue that happens all too often. It is the same issue that has clearly been going on for the 25 years since I started answering questions. Poor question asking skills.

My example story is going to be data centric, but if follows for pretty much any programming question.

The ask

Very often a person asks a question something like this:

“If I have rows in a table, how do I sum them up?”

Can one guess what you mean? In this case, probably. But just as often the question will not make a whole lot of sense without context. Maybe the business problem is not the typical, simple, straightforward question. Maybe because the poster didn’t think about what everyone looking at will need.

Ideally, in addition to your description of your problem if you add more details like:

“If I have rows in a table, how do I sum them up? For example, say I have the following rows in a table:



















The output I would like to get is something like:



Here is the code to build the sample table I have been building with. I am working with SQL Server 2022, Developer Edition.

Executing @@version returns:

Microsoft SQL Server 2022 (RTM) - 16.0.1000.6 (X64) Oct 8 2022 05:58:25 Copyright (C) 2022 Microsoft Corporation Developer Edition (64-bit) on Windows 10 Pro 10.0 <X64> (Build 22621: )

By taking these extra few minutes, you have provided people who want to help you with the infrastructure to get that done. The person helping knows what RDBMS you are using and can have the same code you have tried.

The responder now just has to paste that code into a window, run it and write the query:

And now your problem is solved.

The reality

It isn’t always this easy to formulate questions. When I ask a question, I always forget something. For example, the one I forget very often is to include the exact version of database system I am using. This isn’t needed every time, but it never hurts.

When asking about performance problems, you may not reasonably be able to send enough sample data to reproduce every problem, but share as much as you can. The query or explain plan, row counts, table structures with indexes, etc. In your initial question, provide everything you can reasonably provide. It isn’t horrible for someone to need more than you provide, unless you provide nothing.

In cases where you simply have to include lots of data, it is best to generate that data in a repeatable manner if possible. This is how I ended up writing this blog about generating repeatable test sets, so I could send a question to someone helping me out with a pretty complex graph query. I needed to generate hundreds of thousands of rows, and creating a random set of data that is quite large and repeatable was necessary. Making a backup available somewhere that feels safe can work, too.

The fact is, if you want someone to help you with your coding issues, you need to provide as much detail as you can. You are literally asking them for free consulting. If you ask a vague question, you are more than likely going to get back terrible or annoyed answers. It is never promising when all of the replies start “I think I might know what you are asking.”

The concern

Privacy. So far, I have exhorted you to share as much as possible. Be careful to avoid including real data or sharing backups, no matter how much you feel like you have anonymized your data. Unless you are sending it specifically to a known entity in a safe manner, any slip could be disastrous!

Making your test and development data that you work with have a similar profile as your real data is a good idea. It is nice when doing many types of testing that you have a copy of your production data to do final testing (for example to let user view their data, to support a production issue, or even to compare results in QA testing to a production report.).

But just like unit tests, most of the time when asking for help, unless you are asking for help with specific values, using simple amounts like the $10 amounts I used in my example are fine. I know having to make up data can make the process of building a sample data set harder, but it is clearly essential that nothing you post can be deciphered to be real data.

This isn’t always just making sure that names have been anonymized. While in most cases, clearing out names and addresses (including email and phone) is probably enough, I would suggest that you consider any real data to have meaning.

Be aware of whether your table designs can be shared as well. You may not be allowed to share the structures on the internet as well. Plus, your tables probably contain a lot more detail that you will need for more examples.

I know you might be thinking “This sounds like a lot. Maybe I should just stick to the simple question?” but that is not my point at all. In reality, what I am saying is that building your example data set will help people answer your questions fast (and a lot of times that might be you once you have simplified the problem down to just the data that is needed to answer your question and knowing what the output should look like.

The result

Give people willing to give you free help all the details you can get. When choosing questions to answer, it is easy to say, “nah!” and move on to the next question when you see a question with no details. If you provide sample data and expected results with your question, people will be racing to answer your question and you will likely get multiple answers to choose from.