I understand that rpc_completed is defined as the completion of a remote procedure call and sql_batch_completed is the completion of a t-sql batch. However can anyone explain in concrete terms what the difference is? When should I use one and when should I use the other? Will most/all SQL commands trigger both events?
Asked
Active
Viewed 1,752 times
1
Kenneth Fisher
- 24,127
- 12
- 61
- 114
1 Answers
5
The difference is how the command is executed by the client. The client can directly execute a stored procedure or the client can send a sql batch.
To call a stored procedure from .NET you would use
SqlCommand sqlCmd = new SqlCommand();
sqlCmd.CommandType = CommandType.StoredProcedure;
and to execute a batch you would use
SqlCommand sqlCmd = new SqlCommand();
sqlCmd.CommandType = CommandType.Text;
There are other things you need to set up like the connection, but the above shows the difference between the two execution modes.
Sebastian Meine
- 9,125
- 1
- 27
- 32
sp_completed(or sqlserver.module_end for XE) event. If you are interested in the parameters too, have a look at http://sqlity.net/en/976/capturing-parameters-of-a-stored-procedure-call/ – Sebastian Meine Nov 06 '13 at 20:42