OLE DB provider 'MSDASQL' returned an unexpected data length for the fixed-length column

  • Hi,

    When I tried executing the following query, I got the error as follows.

    Please tell me, how I can sort this out..

    SELECT

    IM_CODE,

    IM_OS_UT_ACCUMULATION,

    IM_OS_ZA_SEC_9B_DEF,

    IM_OS_ZA_RSC_REGION_DEF,

    IM_OS_VOLATILITY,

    IM_OS_RI_RIGHTS_ENTITLE,

    IM_OS_RI_SHARE_SPLIT,

    IM_OS_DIV_CURR,

    IM_OS_XD,

    CASE WHEN IM_OS_BN_DUE_DATE = 0

    THEN NULL

    ELSE CONVERT(DATETIME, IM_OS_BN_DUE_DATE - 36525)

    END AS BN_DUE_DATE,

    CASE WHEN IM_OS_RI_DUE_DATE = 0

    THEN NULL

    ELSE CONVERT(DATETIME, IM_OS_RI_DUE_DATE - 36525)

    END AS RI_DUE_DATE,

    IM_OS_OPTION_TRADED,

    IM_OS_ISSUE_CAPITAL,

    IM_OS_TERM_TO_LISTING,

    IM_OS_NEW_ISSUE,

    IM_OS_MAIN_BOARD_LIST,

    IM_OS_EARN,IM_OS_NTA,

    IM_OS_LOT,

    CASE WHEN IM_OS_DIV_DUE_DATE = 0

    THEN NULL

    ELSE CONVERT(DATETIME, IM_OS_DIV_DUE_DATE - 36525)

    END AS DIV_DUE_DATE,

    IM_OS_CAPITAL,IM_OS_BETA,

    IM_OS_ANNUAL_DIV,

    IM_OS_PAID_UP_VALUE,

    IM_OS_PAR

    FROM OPENQUERY(DB1, 'SELECT * FROM TBL1 WHERE IM_CATEGORY = ''OS'' OR IM_CATEGORY = ''RI''')

    /********************/

    Error

    /*********************/

    Server: Msg 7347, Level 16, State 1, Line 1

    OLE DB provider 'MSDASQL' returned an unexpected data length for the fixed-length column '[MSDASQL].IM_OS_DIV_DUE_DATE'. The expected data length is 6, while the returned data length is 0.

    OLE DB error trace [Non-interface error: Unexpected data length returned for the column: ProviderName='MSDASQL', TableName='[MSDASQL]', ColumnName='IM_OS_DIV_DUE_DATE', ExpectedLength='6', ReturnedLength='0'].

    /***************************/

    Kindly help me on this issue..

    Regards,

    Ezhilan

  • I reply not because I know the solution but I want to share that I got the same problem with MySQL linked server (through ODBC). It seems that the problem occurs with columns with CHAR(1) and CHAR(2) data types when the data is empty. NULL does not create errors.

    I have searched for several hours and found no clear solution. Now all I can do is avoiding those columns in the queries.

  • I have also seen this issue and have not yet found a permanent fix for it. I did see something from Microsoft about this error but that deals with Host Integration Server 2004. That may be what is causing my issue even though my link server is another SQL Server. The original source of the data is coming from DB2. I am wondering if that somehow the error carries through....

    I did seem to find a way to can get around the error. For the column with the issue, CONVERT it to something. In my case, with my column EmployeeType, I changed it to CONVERT(VARCHAR,EmployeeType) as [EmployeeType]. This allows me to get the data back as long as it is not used as part of the WHERE statements.

    In case your issue is related to HIS2004, here is the link from Microsoft:

    support.microsoft.com/kb/897246

    Hope this helps!

    Chad

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply