如何查看 Sql Server 2000 上 SqlClient 数据提供程序最后运行的 SQL 查询?
虽然我已经能够看到最后运行的查询(这是执行的存储过程),但我没有获得调用 SP 的参数值。相反,我得到了以下内容:
StoredProcedureName;1
从以下命令:
DBCC INPUTBUFFER(SPID)
我在哪里通过在 ObjectExplorer->Management->ActivityMonitor 中查看 SPID 来获取 SPID
有什么方法可以获取完整的文本,包括执行 SP 所用的参数?
Although I have been able to see the last ran query which is a Stored Procedure executed but I didn't get the parameters values with which the SP was invoked. Rather I got the following:
StoredProcedureName;1
from the following command:
DBCC INPUTBUFFER(SPID)
Where I got the SPID by viewing it in the ObjectExplorer->Management->ActivityMonitor
Is there any way I can get the complete text including the parameters with which the SP was executed ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我知道这个答案可能不是您正在寻找的,因为它并没有真正回答您的问题,我想了想,最终认为这可能会有所帮助。
我不知道您有多少查询以及您的程序有多大......但出于调试目的,我想对我的所有查询(纯文本和存储过程)执行类似的操作。因此,我编写了一个简单的包装类,它允许我执行带参数和不带参数的纯文本查询/存储过程。然后,如果发生异常,我会捕获它,使用原始异常加上已执行的查询和所有参数构建新的自定义异常,并在自定义消息中返回所有异常。我在包装器中使用 Oracle,但它几乎完全相同:
I know this answer may not be what you are looking for, as it doesn't really answer your question, I took a leap of thought and ended up thinking this might help.
I don't know how many queries you have and how big your program is... but for debugging purposes I wanted to do something similar for all of my queries, both plain text and stored procedures. So I wrote a simple wrapper class that lets me execute plain text queries/stored procs with and without parameters. Then, if an execption occurs, I trap it, build a new custom exception with the original exception plus the query that was executed and all parameters, and return it all in a custom message. I'm using Oracle in my wrapper but it's almost exactly the same: