138

I've been around SO since almost the beginning, and in that time I've answered a LOT of SQL related questions. One point of pain in this area has always been posting sample data or query results. We've had to use ascii table formatting in <pre> blocks or indented for code blocks, with further tricks to keep syntax highlighting from doing weird things. This is tedious and slow to do, both for askers and answerers.

This was asked about and declined previously. Many more times than that, I'm sure. But that was back in 2010. And for nearly 8 years now I've been content to leave it at that.

I'm bringing this up again because I've experienced a disturbing trend where it seems that questions increasingly include a screen-capture from sqlPlus or Management Studio, rather than real sample data. I've noticed this more in other areas, too, and we may want to think about treating images in posts as a potential signal for low-quality generally, as well as a way to address that... but for the moment I want to think about SQL questions.

We could really use an easier method for getting sample data or results into Stack Overflow in a nice tabular or DDL/DML format that is easier for new users to discover. Preferably something that also wraps properly on the mobile app. Ideally the ability to copy/paste from the common query tools... perhaps a "paste data" button on the toolbar that evaluated the clipboard contents to create a nice table.

This isn't a new request, but I believe it is something that has sat idle for a while and may deserve a new look.

21
  • Side note: the time frame for the post in that link made me realize we are rapidly approaching SO's 10th anniversary! Commented Apr 10, 2018 at 15:48
  • Sigh... once again the victim of search fail. I did look, but more research after I post (of course) finds this request: meta.stackoverflow.com/questions/298973/… Commented Apr 10, 2018 at 15:54
  • 54
    I am for anything that reduces the number of screenshots of text.
    – BSMP
    Commented Apr 10, 2018 at 15:54
  • In fairness, that other request is asking for a lot more. I don't know that a full "CREATE TABLE" is necessarily a good idea, since not all DBMS have the same syntax here. Commented Apr 10, 2018 at 15:55
  • 1
    @BSMP The sad thing is I don't know if this will actually help much, because I've also seen so many posts with code images in recent months in other tag areas, too. But this does address a pain point. Commented Apr 10, 2018 at 15:56
  • When Q&A finally switches to CommonMark, this will be possible.
    – user247702
    Commented Apr 10, 2018 at 15:57
  • 1
    @Stijn I didn't think CommonMark had any native table support. I assumed we'd need something to help build the ascii table/pre blocks automatically from tab or comma-delimited source data on the clipboard. What blocker in MarkDown does CommonMark relieve? Commented Apr 10, 2018 at 18:51
  • It doesn't by default, but it allows for extensions. The CommonMark parser that was used for Docs supports tables, and Q&A is supposed to switch to that parser at some point.
    – user247702
    Commented Apr 10, 2018 at 20:45
  • Relevant: meta.stackexchange.com/questions/238957/…
    – DavidG
    Commented Apr 10, 2018 at 22:57
  • 8
    @BSMP i also dislike screenshots of text
    – Tanner
    Commented Apr 10, 2018 at 23:30
  • Just linking: Tips for asking a good Structured Query Language (SQL) question as it seems loosely related to asking a good SQL question.
    – Tanner
    Commented Apr 10, 2018 at 23:37
  • 1
    I think this a great idea as with the traffic of SQL questions (currently 435,144) with a lot of them needing/providing sample data in the form of code text which the formatting could screw up to then be a long process fixing it or screenshots of data which some people might not be able to view, would make these questions a lot more useful which is the aim here really Commented Apr 11, 2018 at 9:25
  • 2
    Not just SQL questions, obviously. Whenever an Excel spreadsheet problem could be solved with an SQL statement against the Excel data, having the sample data makes it much easier to build said statement.
    – Zev Spitz
    Commented Apr 11, 2018 at 13:12
  • 1
    @JonasStaudenmeir And when SqlFiddle goes down (which it does regularly, what do we do?
    – DavidG
    Commented Apr 11, 2018 at 16:24
  • 3
    Please do not encourage people to post their sample data in a tabular way. I too answer a lot of SQL questions (though for a shorter period of time), and share your frustration. However, Sample data is best served as DDL + DML (this is a part of one of my regular comments on SQL questions) - Perhaps it's better to think of a way to incorporate automatic generation of dml+ddl from tabular data. Commented Apr 12, 2018 at 10:30

0

You must log in to answer this question.

Browse other questions tagged .