Generates a Structured Query Language (SQL) query based on a client-supplied query string expressed in either Advanced Query Syntax (AQS) or Natural Query Syntax (NQS).
HRESULT GenerateSQLFromUserQuery( LPCWSTR pszQuery, LPWSTR *ppszSQL );
A pointer to a null-terminated Unicode string containing a query in AQS or NQS.
Receives the address of a pointer to a SQL query string based on the query in the pszQuery parameter.
If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
This method generates SQL in the following form:
SELECT <QuerySelectColumns> FROM <CatalogName that created query helper> WHERE <Result of interpreting the User query passed into this function according to QuerySyntax> [ AND|OR <QueryWhereRestrictions>]
ISearchQueryHelper::GenerateSQLFromUserQuery uses regional locale settings. However, ISearchQueryHelper does not use the regional locale settings. As a result, there are inconsistencies in the SQL returned from ISearchQueryHelper::GenerateSQLFromUserQuery and ISearchQueryHelper for region specific settings such as date formats. For example, if you set the locale for date/time to something other than the system locale, such as en-CA if the system locale is en-US, and enter
Toybox -m -i "date:3/7/2008" -Y -s, the SQL returned will differ. The SQL from ISearchQueryHelper::GenerateSQLFromUserQuery will have parsed 3/7/2008 according to en-CA (seeking items dated 3rd of July, 2008) while the SQL from ISearchQueryHelper will have parsed 3/7/2008 according to en-US (seeking items dated 7th of March, 2008).
The DSearch code sample, available on Code Gallery and the Windows 7 SDK, demonstrates how to create a class for a static console application to query Windows Search using the Microsoft.Search.Interop assembly for ISearchQueryHelper.
|Minimum supported client||Windows XP with SP2, Windows Vista [desktop apps only]|
|Minimum supported server||Windows Server 2003 with SP1 [desktop apps only]|
|Redistributable||Windows Desktop Search (WDS) 3.0|