Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

Using a field alias in Query does not work with some third-party databases


View products that this article applies to.

Symptoms

When you try to use Microsoft Query to return data from some third-party databases into Microsoft Excel, apostrophes (') around alias names can cause the query to fail. The error message that you receive depends on the data source that you use.

↑ Back to the top


Cause

This behavior is the result of a design change in Microsoft Query. Apostrophes are now automatically used when aliasing, to prevent errors that are caused by an alias that contains spaces or reserved words.

↑ Back to the top


Resolution

A supported hotfix is available from Microsoft. However, this hotfix is intended to correct only the problem that is described in this article. Apply this hotfix only to systems that are experiencing this specific problem.

If the hotfix is available for download, there is a "Hotfix download available" section at the top of this Knowledge Base article. If this section does not appear, submit a request to Microsoft Customer Service and Support to obtain the hotfix.

Note If additional issues occur or if any troubleshooting is required, you might have to create a separate service request. The usual support costs will apply to additional support questions and issues that do not qualify for this specific hotfix. For a complete list of Microsoft Customer Service and Support telephone numbers or to create a separate service request, visit the following Microsoft Web site: Note The "Hotfix download available" form displays the languages for which the hotfix is available. If you do not see your language, it is because a hotfix is not available for that language.


Excel 2003 and Excel 2007

You do not have to download anything to fix this problem in Microsoft Office Excel 2003 or in Microsoft Office Excel 2007. See the "More Information" section of this article for instructions about how to enable this functionality

Excel 2002

The global Excel 2002 version of this hotfix has the file attributes (or later) that are listed in the following table. The dates and times for these files are listed in coordinated universal time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.
File nameFile sizeDateTime
Msqry32.msp2,100,76024-Sep-200201:29
Msqry32_admin.msp1,331,42424-Sep-200203:52
After the hotfix is installed, the following files will have the listed attributes or later:
File nameFile versionFile sizeDateTime
Msqry32.exe10.0.4510.0739,91213-Sep-200203:52
Excel 2000

The global Excel 2000 version of this hotfix has the file attributes (or later) that are listed in the following table. The dates and times for these files are listed in coordinated universal time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.
File nameFile sizeDateTime
Msqry32.msp1,166,69208-Nov-200213:41
Msqry32_admin.msp1,419,62808-Nov-200216:36
After the hotfix is installed, the following files will have the listed attributes or later:
File nameFile versionFile sizeDateTime
Msqry32.exe9.0.0.69191,089,53619-Sep-200220:31
After you install this hotfix, follow the steps that are listed in the "More Information" section of this article to set the AllowAlias registry key and to activate the hotfix.

Note After you install the fix that is described in this article, and set the AllowAlias registry key, Microsoft Query will behave as it did in Excel 97.

↑ Back to the top


Workaround

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

To work around this issue, add quotation marks to the alias from inside Microsoft Query. To do this, follow these steps:
  1. Double-click the field name in Microsoft Query.
  2. In the Edit Column dialog box, type your field name alias surrounded by quotation marks.

    For example, type
    "Fred" (with the quotation marks), and then click
    OK.

    After you have returned the data back to Excel, you can use Microsoft Visual Basics for Applications (VBA) to modify the SQL and remove the quotation marks from a QueryTable or from a PivotTable:
    ActiveSheet.Querytable(1).SQL = "new sql string"
    ActiveSheet.PivotTables(1).Pivotcache.Commandtext = "new sql string"

↑ Back to the top


Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section of this article.

↑ Back to the top


More Information

Important This section, method, or task contains steps that tell you how to modify the registry. However, serious problems might occur if you modify the registry incorrectly. Therefore, make sure that you follow these steps carefully. For added protection, back up the registry before you modify it. Then, you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click the following article number to view the article in the Microsoft Knowledge Base:
322756 How to back up and restore the registry in Windows
After you install this hotfix, follow these steps to set the AllowAlias registry key and to enable the hotfix. Use the appropriate steps for your version of Excel.

Excel 2010

You do not have to install the hotfix. To enable this hotfix, follow these steps:
  1. Exit all Office programs..
  2. Click Start, and then click Run.
  3. In the Open box, type regedit, and then click OK.
  4. Locate, and then click to select the following registry subkey:  HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\query\optionsAfter you select the subkey that is specified in step 4, point to New on the Edit menu, and then click DWORD Value.
  5. Type AllowAlias, and then press ENTER.
  6. Right-click AllowAlias, and then click Modify.
  7. In the Value data box, type 2, and then click OK.
  8. On the File menu, click Exit to exit Registry Editor.

Excel 2007

You do not have to install the hotfix. To enable this hotfix, follow these steps:
  1. Exit all Office programs..
  2. Click Start, and then click Run.
  3. In the Open box, type regedit, and then click OK.
  4. Locate, and then click to select the following registry subkey:
    HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\query\options
  5. After you select the subkey that is specified in step 4, point to New on the Edit menu, and then click DWORD Value.
  6. Type AllowAlias, and then press ENTER.
  7. Right-click AllowAlias, and then click Modify.
  8. In the Value data box, type 2, and then click OK.
  9. On the File menu, click Exit to exit Registry Editor.
Excel 2003

You do not have to install the hotfix. To enable this hotfix, follow these steps:
  1. Exit all Office programs..
  2. Click Start, and then click Run.
  3. In the Open box, type regedit, and then click OK.
  4. Locate, and then click to select the following registry subkey:
    HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\query\options
  5. After you select the subkey that is specified in step 4, point to New on the Edit menu, and then click DWORD Value.
  6. Type AllowAlias, and then press ENTER.
  7. Right-click AllowAlias, and then click Modify.
  8. In the Value data box, type 2, and then click OK.
  9. On the File menu, click Exit to exit Registry Editor.
Excel 2002

This update was first included in Office XP Service Pack 3. For additional information about the latest service pack for Office XP, click the following article number to view the article in the Microsoft Knowledge Base:
307841 How to obtain the latest Office XP Service Pack
To enable this hotfix, follow these steps:
  1. Exit all Office programs..
  2. Click Start, and then click
    Run.
  3. In the Open box, type
    regedit, and then click OK.
  4. Locate, and then click to select the following registry subkey:
    HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\query\options
  5. After you select the subkey that is specified in step 4, point to New on the Edit menu, and then click
    DWORD Value.
  6. Type AllowAlias, and then press ENTER.
  7. Right-click AllowAlias, and then click
    Modify.
  8. In the Value data box, type
    2, and then click OK.
  9. On the File menu, click
    Exit to exit Registry Editor.
Excel 2000

To enable this hotfix, follow these steps:
  1. Exit all Office programs..
  2. Click Start, and then click
    Run.
  3. In the Open box, type
    regedit, and then click OK.
  4. Locate, and then click to select the following registry subkey:
    HKEY_CURRENT_USER\Software\Microsoft\Office\9.0\query\options
  5. After you select the subkey that is specified in step 4, point to New on the Edit menu, and then click
    DWORD Value.
  6. Type AllowAlias, and then press ENTER.
  7. Right-click AllowAlias, and then click
    Modify.
  8. In the Value data box, type
    2, and then click OK.
  9. On the File menu, click
    Exit to exit Registry Editor.

↑ Back to the top


References

If you do not have to use aliasing with Microsoft Query, you can turn off aliasing completely.

For additional information about how to turn off aliasing in Microsoft Query, click the following article number to view the article in the Microsoft Knowledge Base:
259347 XL2000: Error Message: ORA-00923:FROM Keyword Not Found Where Expected

↑ Back to the top


Keywords: kbqfe, kbhotfixserver, kbofficexpsp3fix, kbbug, kbfix, kb, kbautohotfix

↑ Back to the top

Article Info
Article ID : 298955
Revision : 3
Created on : 8/20/2020
Published on : 8/20/2020
Exists online : False
Views : 210