How do I get parameter values for SQL Server query in SQL Server Profiler

ぃ、小莉子 提交于 2019-11-29 13:23:12

I think you need the RPC:Completed event:

http://msdn.microsoft.com/en-us/library/ms175543.aspx

The Profiler will contain the parameter values in the RPC:Completed/RPC:Starting events. But you already got replies telling you this.

What I want to add is that is very little need to know the parameter run-time values in order to analyze a deadlock graph. First, because if 'users' is involved in the deadlock, the deadlock graph itself will give away what @id is the conflict, if the conflict is on a key. Second, more importantly, for a deadlock scenario is irrelevant the exact keys that are involved. Is not like a deadlock happens because one deletes user with id 123 but will not happen when it deletes user 321.

If you decided to ask on SO in the first place, I think the best would be to post the actual deadlock graph and let the community have a look at it. There are many here that can answer quite a few questions just from the deadlock graph XML.

Start a trace with the following events having all checkboxes checked:

SQL: BatchCompleted
SQL: BatchStarting
Deadlock graph
Lock:Deadlock
Lock:Deadlock chain

After the deadlock occurs, stop the trace, then click on the deadlock graph event class.

This should give you a good idea of what's going wrong.

If you're using a stored procedure (which it looks like you are) or Hibernate/NHibernate you might need to turn on the Stored Procedures starting event (SP:StmtStarting) and RPC:Starting event. This will show the parameters in it's own line after the query.

Something like:

SP:StmtStarting DELETE FROM users WHERE id = @id

RPC:Starting exec sp_execute 12345

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!