I am running a query from SQL Server 2019(64bit) SSMS to PostgreSQL on AWS through Linked Server. Other queries are working fine but this particular query is failing due to message column. My query is as follows:
SELECT * from OPENQUERY (ABC, 'SELECT id,
old_message,
message
FROM actions;')
Error Message:
OLE DB provider 'MSDASQL' for linked server 'DRIQ' returned data that does not match expected data length for column '[MSDASQL].message'. The (maximum) expected data length is 1400, while the returned data length is 1510.
Query is working fine without message column. But when I add message column, it start giving me an above error. The datatype of message column is JSON in postgres db. For ODBC, I am using 64bit Unicode(x64) and compatibility level of my db is 150. So how to get the data of message(json) column in sql server 2019?
Best Answer
Try with a different driver?
SQL Server and PostgreSQL Linked Server Configuration
You might also want to try implicitly casting the columns to tsql datatypes, i.e.