Share via

Call DB2 Stored Procedure from MSSQL Stored Procedure

Michael Henderson 136 Reputation points
2020-10-28T19:47:20.72+00:00

Does anyone know a way to call a DB2 stored procedure from a MSSQL stored procedure?

The DB2 stored procedure does not pass any parameters and is a simple update.

For example, this does not work:

EXECUTE('{CALL DB2SCHEMA.DB2PROC()}') AT DB2;

Thank you

Developer technologies | Transact-SQL
Developer technologies | Transact-SQL

A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.


Answer accepted by question author

MelissaMa-msft 24,246 Reputation points Moderator
2020-10-29T01:16:24.433+00:00

Hi @Michael Henderson

Thank you so much for posting here.

I did some searching since I have limited knowledge about DB2.

Please refer below methods and check whether any of them is working to you.

  1. To right-click the linked server's "properties" then -> "Server option" The "RPC" and "RPC Out" option in the right pane need to be TRUE.
  2. To use the Microsoft OLE DB Provider for ODBC Drivers and create a new linked server with this provider.
  3. Try with below code.
    EXEC ('{CALL DB2SCHEMA.DB2PROC()}') AT YourLinkedDB2Server;

Best regards
Melissa


If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Hot issues October--Users always get connection timeout problem when using multi subnet AG via listener. Especially after failover to another subnet

Was this answer helpful?


1 additional answer

Sort by: Most helpful
  1. Michael Henderson 136 Reputation points
    2020-11-03T23:06:23.63+00:00

    I tried your solution.

    I created a link server using the Microsoft driver.
    SELECT statements work but not UPDATES.

    Name P not allowed. SQLSTATE 42602 SQLCODE -113

    Thanks.

    Was this answer helpful?


Your answer

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