Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Let us say you have a stored procedure:</p> <pre><code>CREATE PROCEDURE UpdateTables AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; DECLARE @RowCount2 INTEGER DECLARE @RowCount3 INTEGER DECLARE @RowCount4 INTEGER UPDATE Table2 Set atext = 'a' WHERE atext='b' SELECT @RowCount2 = @@ROWCOUNT UPDATE Table3 Set atext = 'a' WHERE atext='b' SELECT @RowCount3 = @@ROWCOUNT UPDATE Table4 Set atext = 'a' WHERE atext='b' SELECT @RowCount4 = @@ROWCOUNT SELECT @RowCount2 AS Table2, @RowCount3 AS Table3, @RowCount4 AS Table4 END </code></pre> <p>As per <a href="https://stackoverflow.com/questions/1103260/return-number-of-rows-affected-by-update-statements">Return number of rows affected by UPDATE statements</a></p> <p>See also : <a href="https://stackoverflow.com/questions/12197870/access-sql-pass-through-query-creating-sp-error/12198827#12198827">access-SQL pass-through query (creating SP) error</a></p> <p>You can then:</p> <pre><code>Dim dbconn As ADODB.Connection Dim cmd As New ADODB.Command Dim rs As New ADODB.Recordset Dim param As New ADODB.Parameter Set dbconn = New ADODB.Connection dbconn.ConnectionString = ServerConLocal dbconn.Open Set cmd = New ADODB.Command cmd.ActiveConnection = dbconn cmd.CommandType = adCmdStoredProc cmd.CommandText = "updatetables" rs.CursorType = adOpenStatic rs.CursorLocation = adUseClient rs.LockType = adLockOptimistic rs.Open cmd ''Records affected For Each fld In rs.Fields Debug.Print fld.Name &amp; " : " &amp; fld Next End Sub </code></pre> <p>You can also simply create a pass-through query with the single line:</p> <pre><code>UpdateTables </code></pre> <p>Which might return:</p> <pre><code> Table2 Table3 Table4 0 2 0 </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload