Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Applescript to run SQL Server stored procedure on Mac

Hello All,


I'm new to applescript. I've a stored procedure in SQL server that generates a uniqque Jobnumber. I need to run this stored procedure from applescript and display the new job number to the user. How can I achieve this using Applescript? Is there any other alternative? Any suggestion/inputs are welcome.


Thanks

iMac, Mac OS X (10.5)

Posted on Mar 17, 2015 11:00 AM

Reply
4 replies

Mar 24, 2015 9:21 PM in response to AppleScriptNewbie

Ahh, when you said 'SQL server', I didn't realize you meant a remote Microsoft SQL Server.. that does complicate things a little.


In order to call SQL Server from your Mac you're going to need an ODBC driver. There are a couple of them (commercial) that might work, or you could try the JDBC approach via Java (using AppleScript to invoke your Java connection). The specifics of this, though are way beyond me.

Mar 17, 2015 11:36 AM in response to AppleScriptNewbie

There's no simple, direct MySQL interface within AppleScript - that is, you can't (easily) connect to your database directly and execute the stored procedure.


The commonest solution to this is to use the command line mysql interface via do shell script.


set myData to (do shell script "/usr/local/mysql/bin/mysql -u USERNAME -pPASSWORD -e '<SQL statement here>'")


There's a lengthy discussion, including examples, at http://macscripter.net/viewtopic.php?id=24721

Applescript to run SQL Server stored procedure on Mac

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.