DebuggingProgramSometimes or some ides may not provide detailed database exception information. SQL Server Profiler is a graphical user interface for SQL tracking. It can monitor database engines and analysis services. When using LINQ to SQL or ADO. NET Entity Framework, you can use it to clearly understand the statements they have executed on the database. We can also use it to track database exceptions.
SQL Server Profiler is opened by starting --> All Programs-> Microsoft SQL Server 2008 --> Performance Tools-> SQL Server Profiler.
Click file --> Create trail, enter the database connection information, and select connection. By default, the standard template is used. It does not track exceptions. If you want to track exceptions, switch to the "Event Selection" tab first.
Click Show all events in the lower right corner, and select the check boxes before exception and user error messages in errors and warnings. Other check boxes can be selected as needed. After the selection is complete, run the task on a single machine and start tracking.
Then execute the program to be debugged and let it perform database operations. If you have selected some check boxes under tsql, SQL Server Profiler records the T-SQL statements executed by the program. When an exception occurs in the query, SQL Server Profiler records the exception information and displays it, just like querying in SQL Server Management studio.
This tool can also be used to track database exceptions in non-debugging environments.
This article applies to Microsoft SQL Server 2008, Microsoft SQL Server 2008 SP1