I've written a query in postgres (on PGAdmin) and I'd like to put it in SSMS2012 for reporting purposes however it doesn't seem to allow the CASE statement, this is my query:
SELECT *
FROM OPENQUERY (POSTGRESQL,
'SELECT
Table1 AS Table_1,
CASE Table2
WHEN 75887 THEN ''1''
WHEN 75888 THEN ''2''
WHEN 75889 THEN ''3''
WHEN 75890 THEN ''4''
WHEN 75891 THEN ''5''
WHEN 75892 THEN ''6''
END AS Table_2,
DateTable1 AS DateTime
FROM SuperTable1 ')
And I'm getting the error:
OLE DB provider "MSDASQL" for linked server "POSTGRESQL" returned message "Requested conversion is not supported.".
Msg 7341, Level 16, State 2, Line 1
Cannot get the current row value of column "[MSDASQL].table_2" from OLE DB provider "MSDASQL" for linked server "POSTGRESQL".
I've noticed if I remove the whole case statement it has no issues retreiving the data in the columns in the SELECT statement and the whole thing (including the CASE statement) works fine in PGAdmin.
Table2? - extremely strange naming conventions - a_horse_with_no_name