Query works via ODBC, but fails when using OLEDB MSDASQL "Microsoft OLE DB Provider for ODBC Drivers"

Karl-D 21 Reputation points
2023-05-30T19:41:28.2866667+00:00

So I got this Linked Server from Microsoft SQL Server to a Rocket U2 Universe setup a while back per https://learn.microsoft.com/en-us/answers/questions/1089893/connect-to-u2-universe-db-as-a-linked-server-in-mi

But I need some help understanding why certain things work through the ODBC connection, but fail when running through the OLEDB MSDASQL "Microsoft OLE DB Provider for ODBC Drivers"...

For example, most tables, I can query fine in Microsoft SQL Server Management Studio via the Linked Server configuration above. However, some, like the example below, give me errors. What's odd is that if I connect from another application (like PowerBI) directly to the ODBC (bypassing OLE DB), they work fine.

Is there a way to configure OLEDB to prevent issues like this?

SELECT * FROM [MYLINKEDSERVER]...[PROD_DET];

Msg 7354, Level 16, State 1, Line 1

The OLE DB provider "MSDASQL" for linked server "MYLINKEDSERVER" supplied invalid metadata for column "AVG_COST_PD". The precision exceeded the allowable maximum.

SQL Server Other
0 comments No comments
{count} votes

Accepted answer
  1. Erland Sommarskog 121.4K Reputation points MVP Volunteer Moderator
    2023-05-30T21:27:46.19+00:00

    Seems like you are running into a limitation in SQL Server. In SQL Server, the maximum possible precision for the decimal data type is 38. Other environments may have different limits. Also, some environment may have a more dynamic decimal data type where precision/scale depends on the actual value. Then again, this must be reported as something fixed to SQL Server, since all values in a column must have the same data type.

    I don't know anything about Rocket U2 Universe, but you may need to run something like this:

    SELECT col FROM OPENQUERY('ROCKETU2', 'SELECT cast(col AS decimal(38,10)) FROM tbl')
    

    To force a data type that SQL Server can handle.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.