请问SQL Profiler中下面4个事件的真正区别

ChinaITOldMan 2018-10-22 04:32:46
请问SQL Profiler中下面4个事件的真正区别是什么?谢谢

SQL:StmtCompleted 在完成了 Transact-SQL 语句时发生。
SP:StmtCompleted 指示存储过程中的 Transact-SQL 语句已执行完毕。
SQL:BatchCompleted 在完成了 Transact-SQL 批处理时发生。
RPC:Completed: 在完成了远程过程调用 (RPC) 时发生。
...全文
322 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
ChinaITOldMan 2018-10-27
  • 打赏
  • 举报
回复
thanks all of you!
又又0916 2018-10-26
  • 打赏
  • 举报
回复
引用 7 楼 zjcxc 的回复:
SP 的问题,你写程序,用存储过程的调用方法
参考:
https://docs.microsoft.com/en-us/dotnet/api/system.data.sqlclient.sqlcommand?view=netframework-4.7.2
重点设置
SqlCommand .CommandType =CommandType.StoredProcedure


谢谢!
zjcxc 2018-10-26
  • 打赏
  • 举报
回复
SP 的问题,你写程序,用存储过程的调用方法
参考:
https://docs.microsoft.com/en-us/dotnet/api/system.data.sqlclient.sqlcommand?view=netframework-4.7.2
重点设置
SqlCommand .CommandType =CommandType.StoredProcedure

又又0916 2018-10-25
  • 打赏
  • 举报
回复
引用 4 楼 zjcxc 的回复:
SP:StmtCompleted 指示存储过程中的 Transact-SQL 语句已执行完毕。 RPC:Completed: 在完成了远程过程调用 (RPC) 时发生。 ---这两个都是 stored procedure 中的事件,和 SQL 的两个对应
你好,网上的另外一个回答好像说RPC:Completed指的是sp_executesql执行完毕,我测了一下是这样,而普通SP是不会触发这个事件的。 我是初学者,如果这个说法不对,请您指正。 https://dba.stackexchange.com/questions/34484/difference-between-sql-batch-statement-and-rpc RPC" vs "batch" is the TDS execution mode that ADO.NET (or any SQL Server client) uses. When a plain SQL statement with no parameters is executed, we use a "batch". When a stored-proc is executed, we use RPC (this is not the same as RPC as the stand-alone network remote procedure call, we just happen to call this mode RPC in TDS (the SQL Server network protocol)). Also, if you execute a batch with parameter, we actually use a stored-proc called sp_executesql, and pass the SQL statement itself and the rest of the parameters to it, so it also shows up as RPC. Pablo Castro Program Manager - ADO.NET Team Microsoft Corp.
ChinaITOldMan 2018-10-25
  • 打赏
  • 举报
回复
谢谢ZJCXC老大与版主
zjcxc 2018-10-24
  • 打赏
  • 举报
回复
SP:StmtCompleted 指示存储过程中的 Transact-SQL 语句已执行完毕。
RPC:Completed: 在完成了远程过程调用 (RPC) 时发生。
---这两个都是 stored procedure 中的事件,和 SQL 的两个对应
xiaoxiangqing 2018-10-24
  • 打赏
  • 举报
回复
自己监控一下,对照看可能容易理解一下
zjcxc 2018-10-23
  • 打赏
  • 举报
回复
假设你执行的是SQL:
select 1
select 2
则执行后,在profiler 中可以跟踪到3条

SQL:StmtCompleted 在完成了 Transact-SQL 语句时发生。
这个会捕获两条,分别对应两条 SQL

SQL:BatchCompleted 在完成了 Transact-SQL 批处理时发生。
这个捕获一条,是你执行的完整 SQL

SP 的两个事件类似,你可以创建一个包含多条 SQL 的存储过程测试一下。简单地说,就是批和单语句
吉普赛的歌 2018-10-23
  • 打赏
  • 举报
回复
引用 1 楼 zjcxc 的回复:
假设你执行的是SQL: select 1 select 2 则执行后,在profiler 中可以跟踪到3条 SQL:StmtCompleted 在完成了 Transact-SQL 语句时发生。 这个会捕获两条,分别对应两条 SQL SQL:BatchCompleted 在完成了 Transact-SQL 批处理时发生。 这个捕获一条,是你执行的完整 SQL SP 的两个事件类似,你可以创建一个包含多条 SQL 的存储过程测试一下。简单地说,就是批和单语句
老大忘记了解释最后一个 RPC:Completed 吧?

22,206

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧