Call MS SQL stored procedure from ibm system i (as400)

We are purchasing a third party application that requires data to be sent to an MS SQL server from our system i. We can use a stored procedure on the Windows/SQL side to pull the data, however this is an IBM application process that can be run anytime during the day or night so we would have to schedule the procedure to run very frequently to check for data if we want to do it on the Windows side. We would prefer to be able to push the data to the SQL server as a last step of the IBM i application process.

Does anyone have any experience or ideas on how we could trigger the SQL procedure from the IBM? We are on Version 7.1 Mod 0.
smp2k7Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gary PattersonVP Technology / Senior Consultant Commented:
Lots of ways to handle this:

1) Use JDBC and a Java program on your IBM i to directly connect to the SQL server and insert rows into the target tables.

2) Use JDBC from RPG program using Scott Klements JDBC4R service program:  https://www.scottklement.com/jdbc/

I'll note that using JDBC to do single row inserts for large volumes of data is inefficient.  This works the best when you perform the inserts/updates throughout the day in near real-time.  

If you're doing bulk transfers:

3) You might want to just export the data as a CSV from IBM i (CPYTOIMPF), and then kick off a bulk import script in SQL server.  You could do this on a scheduled basis, or you could remotely invoke the bulk import script from an IBM i program.  For example, you could use the RUNRMTCMD to remotely execute a Windows program or script via the IBM i Access for Windows Incoming Remote Command Service (though I'm not recommending this method any longer due to instability issues when Windows servers are updated to a new service pack or a new OS version).

4) We frequently use ssh to connect from IBM i systems to other IBM i, AIX, Linux, and Unix systems.  Windows doesn't have a native sshd (ssh server), but there are lots of free and commercial sshd servers for Windows available.  ssh allows you to make a command-line connection from the IBM i and securely execute remote commands and perform file transfers to and from the target system.

ssh is a Qshell/PASE command, and has a simple syntax.  Note that for this to work in a a program, you'd need to configure public and private keys to enable password-less authentication, or things get more complicated and you'd have to use something like and Expect script on the IBM i to handle the login using a password (which is insecure anyway).

ssh user1@server1 command1

5) Another relatively easy mechanism to use is to use a folder monitoring solution on Windows.  Use CPYTOIMPF to export your data to a CSV, then transfer the CSV to Windows using the QNTC file system,  Use a folder-monitoring utility on Windows (can just be a simple powershell script that gets started by the scheduler when Windows starts) to watch for a new file and kick off a bulk import script.

If you want more information on any of these options, post back.  

There are also a ton of commercial tools that can help with this, but I think that with just a little effort, it is pretty easy to set up yourself.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Vitor MontalvãoMSSQL Senior EngineerCommented:
smp2k7, do you still need help on this question?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
IBM System i

From novice to tech pro — start learning today.