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

Question:

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?

Solution:1

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.

Solution:2

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.