Linked Server Error while executing a stored procedure

  • Dear All,

    Scenario:

    Server A has a stored procedure which has three select statements. Execution of the stored procedure will return a dataset of three tables

    e.g. Select col1, col2 from tableA AA joins LinkedServer.DB.dbo.TableB BB on AA.ID = BB.ID

    Select col1, col2 from tableA AA joins LinkedServer.DB.dbo.TableB BB on AA.ID = BB.ID

    Select col1, col2 from tableA AA joins LinkedServer.DB.dbo.TableB BB on AA.ID = BB.ID

    The joins in the above statements also includes tables in the local server.

    Problem:

    The execution of the SP creates issues while executing the second select statement. If the second select statement does return some rows, then it fails giving the below error message:

    OLE DB provider "SQLNCLI" for linked server "LNK1" returned message "String data, length mismatch".

    Msg 7421, Level 16, State 2, Line 7

    Cannot fetch the rowset from OLE DB provider "SQLNCLI" for linked server "LNK1". .

    If the second select statement does not return any rows, then the SP execution is successful.

    The rows returned in the second query depends on the data present within a local table included in the join. The first query does not matter in context of whether it returns any rows or not.

    Also, if the first query does not return any rows, and the second query returns rows, the SP execution is successful.

    Is anyting dependent on the number of rows returned while grabbing data from a linked server.. OR anything in this context.

    Can anyone please help. I am stuck in the middle of doing something on this.

    Any help would be appreciated.

    Thanks.

    Regards,

Viewing 0 posts

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