Share via


How to: Edit the Test.sql Script to Run Objects that use SQL Server Common Language Run-time Integration

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.

For example, if your SQL Server Common Language Run-time (SQL CLR) database project contains a stored procedure, you would add to the Test.sql script a line of Transact-SQL that executes the stored procedure. If the stored procedure does not provide any output, then you might want to add a Transact-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 on the View menu.

  2. Expand the Test Scripts folder.

  3. Double-click the Test.sql file to open it in the Transact-SQL editor. If you have multiple test scripts, double-click the test script that you want to open. For more information about how to specify the default debug script, see the second procedure in this topic.

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

To specify a default debug script

  1. In Solution Explorer, expand the Test Scripts folder for the project that you want to configure.

  2. Right-click the script that you want to use as your default debug script, and click Set as Default Debug Script.

See Also

Tasks

Walkthrough: Creating a Stored Procedure in Managed Code

Concepts

Creating SQL Server Objects in Managed Code

Advantages of Using Managed Code to Create Database Objects