Share via


How to: Edit the Test.sql Script to Run SQL Objects

The Test.sql file is where you add Transact-SQL statements that perform the necessary actions to test the database objects in a SQL Server project.

Note

In Visual C++, this file is named debug.sql. If you are using Visual C++ to run SQL objects, replace Test.sql with debug.sql in the instructions below.

For example, if your SQL Server project contains a stored procedure, you would add to the Test.sql script a line of SQL that executes the stored procedure. If the stored procedure does not provide any output, then you might want to add a SQL statement that returns some of the data manipulated by the stored procedure to verify that it executes as expected. Similarly, to test a trigger, your Test.sql file should contain a statement that performs the action that causes the trigger to execute, such as inserting or deleting a row.

The results of the Test.sql script are displayed in the Output window under the Database option in Visual Studio so that you can determine whether your database objects are working correctly.

To edit the Test.sql file in a SQL Server project

  1. Open Solution Explorer by choosing Solution Explorer from the View menu.

  2. Expand the Test Scripts folder.

  3. Double-click the Test.sql file to open it in the SQL Editor.

  4. Add a Transact-SQL statement that will provide results confirming the functionality of your project's database objects. For more information on creating a Test.sql script for the specific items in a SQL Server project, see the following pages:

See Also

Tasks

Walkthrough: Creating a Stored Procedure in Managed Code

Concepts

SQL Server Projects

Advantages of Using Managed Code to Create Database Objects

Other Resources

SQL CLR Database Debugging