Tutorial :How to break on Insert in Visual Studio / SQL Server 2005


II'd like to use Visual Studio to break whenever a record is inserted into a certain table, so I can see the values being inserted and the call stack from that moment. Is that possible, or am I stuck with stored procedure debugging only?


Well, since you're using SqlServer, why not just use Profiler? Set a trace, and you can watch the values insert there.... You can set up the breakpoint in Visual Studio, or you can just set it as a transaction that rolls back, then go through the trace to find the values that would have gone in.

If you haven't used profiler before, it's very easy and should do what I think you're looking to pull off.


Depending on how you are writing your code that is actually performing the database inserts, you could set a breakpoint on the function/sub that is being called and step through it to see the values that are getting passed through, but we would probably need to see more specifically how you are actually performing your database operations in your code.

Edit: As has been said, if you stay out of visual studio, using the SQL Server Profiler is probably your best option.


More effort than it is worth but is possible, could prob create a trigger on the table and use this method http://support.microsoft.com/kb/316549

But like everyone is suggesting, break on the .net code that does the insert or use sql profiler is much, much easier and reliable.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »