Create a reusable ODBC Exec file

If you frequently use File > Query Database (ODBC) to update your worksheet, you can automate the process by creating an Exec file.

Create the Exec file

  1. Import the data using File > Query Database (ODBC).
  2. Click the Show History button on the Project Manager toolbar to open the History window.
  3. Select the ODBC session commands and subcommands, then right-click and choose Save As.
  4. From Save as Type choose Exec Files (*.MTB).
  5. Enter a file name; for example, GetData.MTB.
  6. Choose a location for the file, and then click Save.
  7. To run the Exec file:
    1. Choose File > Other Files > Run an Exec.
    2. Click Select File.
    3. Select the Exec file that you saved and click Open.

Specify output columns in the Exec file

If you want to refresh the data in the same Minitab worksheet every time you run the Exec file, you need to edit the Exec file to specify the columns to use in the Minitab worksheet.

Tip

The maximum number of characters that can occur between double quotation marks on one line is 80. To use text strings longer than 80 characters, break the string into smaller sections across multiple lines using the ampersand (&) key. For example, in the following Session window output, the ampersand is inserted to continue two long text strings in double quotation marks down to the next line.

MTB > ODBC;
SUBC> Connect "DSN=Excel Files;DBQ=C:\DOCUMENTS AND SETTINGS\JSMITH\DESKTOP\jon" &
CONT> "athon.xls;DefaultDir=C:\DOCUMENTS ANDSETTINGS\JSMITH\DESKTOP;DriverId=345" &
CONT> ";MaxBufferSize=2048;PageTimeout=5;";

  1. In Minitab, choose Tools > Notepad.
  2. In Notepad, choose File > Open. Change the file type to All Files(*.*), and open the .MTB file you created.
  3. For each ODBC session command and corresponding subcommands, do the following
    1. Replace the period (.) at the end of the final subcommand with a semi-colon (;), then press the Enter key.
    2. On the following line, specify the columns where you want the data to be stored. For example, enter Columns 'First Name' 'Last Name' 'City' 'Country'.
      Tip

      You can specify a range of column IDs instead of naming each one individually, for example: Columns C1-C10. Specifying a range is especially useful when importing a large number of columns.

      Example of an ODBC exec file

      Edits are highlighted.

      Note

      This example will work only if the columns in the Minitab worksheet are already named to match the Exec file.

  4. Choose File > Save and then close Notepad.

Run the Exec file

  1. Choose File > Other Files > Run an Exec.
  2. Click Select File.
  3. Select the Exec file that you saved and click Open.
By using this site you agree to the use of cookies for analytics and personalized content.  Read our policy