TSQL event and RPC event, difference example?

"

stored procedures can be executed in two different ways:
  1. An RPC event i.e. as a result of a Remote Procedure Call
  2. A Transact-SQL event i.e. as a result of a call to the T-SQL EXECUTE statement

," what is the difference?

 for every RPC event always has TSQL event? could you give some specific example? thanks


June 5th, 2012 2:15pm

Hi George,

An RPC call means that the stored procedure was called from outside the SQL Server instance space.  For example, if you have a web application or windows application which creates a SQL connection string and then makes a call to execute the SP.

A T-SQL event could be a call to the procedure either through Query Analyzer running on the same server, or from within another stored procedure.  The key is that it is running on the server itself, which is why every RPC event has a TSQL event.  The RPC event must initiate a TSQL event, but a TSQL event does not have to initiate a remote call.

For example, let's say there is an SP called from a .NET web service called my_StoredProc_A that looks like this:

CREATE PROCEDURE dbo.my_StoredProc_A

AS

-- do something.

EXECUTE dbo.my_StoredProc_B

-- do something else.

GO

If you ran SQL Profiler trace on this, you would notice that my_StoredProc_A would show up as an RPC event and a TSQL event, but my_StoredProc_B would only show up as a TSQL event because it was not called remotely.

Hope that explains it!

Regards,

Diane.

Free Windows Admin Tool Kit Click here and download it now
June 5th, 2012 5:10pm

IT is up to the programmer to decide how their stored procedure calls should be "packaged" and sent to SQL Server.

They could just submit text, just as when you from a query window type EXEC myproc and press "execute".

Or they could fonfigure the command object (or similat) to be or type "stored procedure" meaning that parameters and such will be sbmitted as binary data instead of just strings. Thsi is more efficient and less likely to risk SQL Injection. In fact, even SELECT (Etc) statements can be sent as RPC calls, if the queries are parameterized and hence using sp_executesql to be executed (through an RPC event). No, every RPC event do not have a TSQL event.

June 5th, 2012 5:27pm

Hi,George 

Here is the definition of RPC come from msdn as below:

https://msdn.microsoft.com/en-us/library/dd303353%28prot.20%29.aspx?f=255&MSPPError=-2147217396

Please note that "RPCs MUST be in a separate TDS message and not intermixed with SQL statements". 

So,as Tibork said that  every RPC event did not have a TSQL event, is correct.

Free Windows Admin Tool Kit Click here and download it now
June 18th, 2015 12:11am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics