How to: Debug Database Objects
09/10/2025 A SQL Server unit test consists: Unit test code written in C# or Visual Basic. This code, which is generated by the SQL Server Unit Test Designer, is responsible for submitting the Trans
A SQL Server unit test consists:
Unit test code written in C# or Visual Basic. This code, which is generated by the SQL
Server Unit Test Designer, is responsible for submitting the Transact-SQL script that forms
the body of the test.
One or more test conditions, which are written in C# or Visual Basic. To debug test
conditions, follow the procedure for debugging a unit test as described in
How to: Debug
while a Test Is Running (Visual Studio 2010)
or
How to: Debug while a Test Is Running
(Visual Studio 2012).
One or more Transact-SQL scripts that run on objects in the database that you’re testing.
You can’t debug these Transact-SQL scripts.
The procedures in this article describe how to debug particular database objects, such as
stored procedures, functions, and triggers in the database you’re testing. To debug a database
object, follow these procedures in this order:
-
Enable SQL Server debugging on your test project.
-
Enable application debugging on the SQL Server instance that hosts the database you’re
testing.
-
Set breakpoints in the Transact-SQL script of the database objects you’re debugging.
-
Debug your unit test. In this procedure, you run the test in debug mode.
-
Open.
-
In
, right-click the test project, and select.
A properties page that has the same name as the test project opens.
-
On the properties page, select.
-
Under
, select.
- Save your changes.