确定存储过程触发了多少个循环
我在 SQL Server 2008 R2 上创建了一个稍微复杂的存储过程,这个 SP 还包含一些用户定义的函数。这些 UDF 和 SP 本身内部有一些 while 循环。
我想确定当我调用此 SP 时某些内容已循环了多少次。
我可以做任何改变吗?
I have created a little complex stored procedure on SQL Server 2008 R2 and this SP also contains some user defined functions. Those UDFs and the SP itself has some while loops inside them.
I would like determine how many times something has been looped when I call this SP.
Any change I can do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,SQL Profiler 没有任何方法可以做到这一点。我要做的是创建一个临时表(假设您只对单个连接的迭代次数感兴趣)来增加单个计数变量,然后您可以输出最后存储在该临时表中的值循环的。
例如:
我创建了一个 id 字段,以防您可能需要多个“计数器”。
SQL Profiler doesn't have any way to do this, as far as I know. What I'd do is create a temporary table (provided you are only interested in the number of iterations for a single connection) to increment the single count variable, and then you can output the value that is stored in that temp table at the end of the loop.
Something like:
I made an
id
field in case there is more than one "counter" you may want.