Create a reusable ODBC Exec file

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

Create the Exec file

  1. Import the data using File > Query Database (ODBC). For more information, go to Import data from a database by using 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, select Exec (*.mtb).
  5. Enter a file name (for example, GetData.MTB).
  6. Select a location for the file and then click Save.
  7. To run the Exec file, do the following:
    1. Choose Tools > Run an Exec.
    2. Specify the number of times that you want to run the Exec.
    3. Click Select File.
    4. Select the Exec file, then 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

In an ODBC SQL or connect string, the maximum number of characters that can occur between double quotation marks on one line is 80. To use text strings that are longer than 80 characters, break the string into smaller sections across multiple lines using the ampersand (&) key. For example, in the following Session window content, the ampersand continues a long text string in double quotation marks down to the next line.

MTB > ODBC;
SUBC> Connect "DSN=Excel Files;DBQ=C:\DOCUMENTS AND SETTINGS\JSABARA\DESKTOP\jon" &
CONT> "athon.xls;DefaultDir=C:\DOCUMENTS AND SETTINGS\JSABARA\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 (*.*), then open the MTB file that 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 to store the data. For example, enter Columns 'First Name' 'Last Name' 'City' 'Country'.This example works only if the columns in the Minitab worksheet are already named to match the Exec file.

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

  4. Choose File > Save, then close Notepad.

Run the Exec file

  1. Choose Tools > Run an Exec.
  2. Click Select File.
  3. Select the Exec file that you saved, then click Open.
Note

To add a shortcut to run the Exec from a menu or toolbar, go to Add a shortcut to a menu or toolbar to run a Minitab macro or Exec file.

By using this site you agree to the use of cookies for analytics and personalized content.  Read our policy