MFC CRecordset UNION Query Failed to open a table - there were no specified columns to retrieve

43 Views Asked by At

The following query works in Azure Data Studio but fails when using MFC CRecordset (with either CRecordset::snapshot or CRecordset::forwardOnly):

(SELECT [id], [location_id], 0 AS [isFromManual], [order_number]
  FROM [shortcuts])
UNION
(SELECT [id], [location_id], 1 AS [isFromManual], [order_number]
  FROM [manual_shortcuts])
ORDER BY [order_number]; 

It works when the parens are removed from the 2 SELECT statements. Note: the parens were left over from earlier development and are obviously neither necessary nor desired.

Using ODBC Driver 18 for SQL Server (v2018.183.01.01), VS2022 using v143 toolset and /std:c++20.

0

There are 0 best solutions below