4

When asking MS Access questions on Stack Overflow that involve tables, how can I post the data in a format that can be easily imported into Access?

With other databases, I can simply just post multiple SQL insert statements. However, MS Access does not allow us to run multiple insert statements in this way.

If I select the records in an MS Access table and copy/paste them into stack overflow, the table turns out like this:

Table Name: road insp

INSP_ID ROAD_ID INSP_DATE   CONDITION
1   100 2009-01-01  0.1
1   100 2011-01-01  0.05
3   100 2012-01-01  0.15
4   100 2015-01-01  0.2
5   100 2017-01-01  0.25
6   200 2009-01-02  0.3
7   200 2001-01-02  0.35
8   200 2013-01-01  0.4
9   200 2017-01-01  0.45
10  300 2009-01-03  0.5
11  300 2011-01-03  0.55
12  300 2014-01-01  0.6
13  300 2015-01-01  0.65
14  300 2017-01-01  0.7
15  300 2017-12-31  0.75
16  400 2009-01-04  0.8
17  400 2011-01-04  0.85
18  400 2014-01-02  0.9
19  400 2015-01-01  0.95
20  400 2017-01-01  1

However, this format hardly seems useful.

  1. It's hard to read.
  2. It doesn't seem to import properly to MS Access as a tab-delimited text file.

How can I post tables on Stack Overflow for easy import into MS Access (for maximum convenience to Stack Overflow community members)?

6
  • 2
    Here is a site with a tool to help format tables ozh.github.io/ascii-tables
    – June7
    Commented Nov 11, 2017 at 6:22
  • Mea Culpa! I fat fingered this one.
    – Martijn Pieters Mod
    Commented Nov 11, 2017 at 8:45
  • 2
    @MartijnPieters Are you sure that this is a duplicate? The answers in the suggested duplicate don't really apply to MS Access, because MS Access can't run multiple SQL statements. So multiple insert statements as DDL are not a practical option. Instead, I'm looking for an alternative option that is suited to MS Access (and it's limitations), which Andre has provided.
    – User1974
    Commented Nov 11, 2017 at 14:04
  • It's the general idea of including tables of data to support the question that I wanted to dupe to. I added another dupe, one about formatting tables.
    – Martijn Pieters Mod
    Commented Nov 11, 2017 at 14:07
  • Ok. Fair enough.
    – User1974
    Commented Nov 11, 2017 at 14:14
  • (A little late to the party...) @MartijnPieters It is possible to construct a solution specifically to run multiple SQL statements for Access: some kind of VBA harness that runs the SQL over an ADODB or DAO connection. Such a solution isn't needed for other SQL systems. Requesting a reopen.
    – Zev Spitz
    Commented Mar 14, 2021 at 19:28

1 Answer 1

5

As June7 wrote: http://ozh.github.io/ascii-tables/

Copy your tab-separated data from Access (or Excel) to "Input" and click "Create".

Copy the ASCII output to the question and format as code.

+---------+---------+------------+-----------+
| INSP_ID | ROAD_ID | INSP_DATE  | CONDITION |
+---------+---------+------------+-----------+
|       1 |     100 | 2009-01-01 |       0.1 |
|       1 |     100 | 2011-01-01 |      0.05 |
|       3 |     100 | 2012-01-01 |      0.15 |
|       4 |     100 | 2015-01-01 |       0.2 |
|       5 |     100 | 2017-01-01 |      0.25 |
|       6 |     200 | 2009-01-02 |       0.3 |
+---------+---------+------------+-----------+

This is (a) nicely formatted to read, and (b) the readers can do the opposite: copy the ASCII to "Output", click "Parse", and copy the tab-separated "Input" to Access or Excel.

3
  • 1
    Wow! I didn't know that it was possible to "do the opposite" with that tool.
    – User1974
    Commented Nov 11, 2017 at 13:27
  • I also didn't know that it was possible to paste tab-delimited data into an Access table using paste options >>> paste append. That is handy.
    – User1974
    Commented Nov 11, 2017 at 13:28
  • 1
    For non-Access situations, SQL Fiddle can be used which has a TEXT to DDL feature.
    – User1974
    Commented Nov 11, 2017 at 13:49

Not the answer you're looking for? Browse other questions tagged .