MsiDatabaseExportA function (msiquery.h)

The MsiDatabaseExport function exports a Microsoft Installer table from an open database to a Text Archive File.


UINT MsiDatabaseExportA(
  [in] MSIHANDLE hDatabase,
  [in] LPCSTR    szTableName,
  [in] LPCSTR    szFolderPath,
  [in] LPCSTR    szFileName


[in] hDatabase

The handle to a database from MsiOpenDatabase.

[in] szTableName

The name of the table to export.

[in] szFolderPath

The name of the folder that contains archive files.

[in] szFileName

The name of the exported table archive file.

Return value

The MsiDatabaseExport function returns one of the following values:

Return code Description
An invalid path is passed to the function.
The function fails.
An invalid or inactive handle is supplied.
An invalid parameter is passed to the function.
The function succeeds.


If a table contains streams, MsiDatabaseExport exports each stream to a separate file.

For more information, see MsiDatabaseImport.

This function cannot be called from custom actions. A call to this function from a custom action causes the function to fail.

If the function fails, you can get extended error information by using MsiGetLastErrorRecord.


The msiquery.h header defines MsiDatabaseExport as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.


Requirement Value
Minimum supported client Windows Installer 5.0 on Windows Server 2012, Windows 8, Windows Server 2008 R2 or Windows 7. Windows Installer 4.0 or Windows Installer 4.5 on Windows Server 2008 or Windows Vista. Windows Installer on Windows Server 2003 or Windows XP
Target Platform Windows
Header msiquery.h
Library Msi.lib
DLL Msi.dll

See also

Database Management Functions

Text Archive Files