Darren
darren at activebilling.com.au
Tue Jun 3 02:06:27 CDT 2014
WOW and WOW again Can't wait to test this stuff. David, thank you so very very much for your efforts - I will advise. Darren -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of David McAfee Sent: Tuesday, 3 June 2014 9:08 AM To: Access Developers discussion and problem solving Subject: Re: [AccessD] A2003: Deploying Stored Procs to SQL Server Now onto the Access part ;) I created a new blank MDB (Actually an ACCDB in 2007). Creat a new query in design view. Change the Query type to a passthrough query Enter your call: EXEC stpDistributeSproc 'YourServerNameHere', 'DBnameHere', 'C:\TestSproc.sql' Create a new Module, paste the following in it: Public Sub ExecuteStoredProcedureWithoutRecordset(strSQLStatement As String) 'Execute a stored procedure without expecting a recordset 'Variables Dim db As Database, qdf As QueryDef Set db = CurrentDb Set qdf = db.QueryDefs("Query1") qdf.SQL = strSQLStatement 'Execute the SQL statement DoCmd.SetWarnings False qdf.ReturnsRecords = False DoCmd.OpenQuery qdf.Name DoCmd.SetWarnings True 'Reset variables Set qdf = Nothing Set db = Nothing End Sub Now create a form with a button on it, place the following code in the OnClick event of the button: Private Sub cmdDistributeSprocs_Click() Dim YourServerName As String, YourDataBaseName As String, YourFilePathAndName As String, strSQL As String YourServerName = "MKDBSRV" YourDataBaseName = "SSIS_Test" YourFilePathAndName = "C:\TestSproc.sql" 'strSQL = "EXEC xp_cmdshell sqlcmd -S " + YourServerName + " -d " + YourDataBaseName + " -i " + YourFilePathAndName 'Debug.Print (strSQL) strSQL = "EXEC stpDistributeSproc '" & YourServerName & "', '" & YourDataBaseName & "', '" & YourFilePathAndName & "'" ' Debug.Print (strSQL) Call modSQLServer.ExecuteStoredProcedureWithoutRecordset(strSQL) End Sub if it all works out ok, you'll only need to keep a table of paths and .sql file names and then open and loop through the record set, calling the function as above, in the onlclick even. Let me know if you need help with that. I have to give credit for calling the sproc from this link: http://blog.ambitionit.nl/archive/2009/07/15/execute-a-stored-procedure-from -an-mdb.aspx HTH David -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com