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
Open Solution Explorer by choosing Solution Explorer on the View menu.
Expand the Test Scripts folder.
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.
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:
For stored procedures, see How to: Create and Run a SQL Server Stored Procedure by using Common Language Run-time Integration.
For triggers, see How to: Create and Run a SQL Server Trigger by using Common Language Run-time Integration.
For user-defined functions, see How to: Create and Run a SQL Server User-Defined Function by using Common Language Run-time Integration.
For user-defined types, see How to: Create and Run a SQL Server User-Defined Type by using Common Language Run-time Integration.
For aggregates, see How to: Create and Run a SQL Server Aggregate by using Common Language Run-time Integration.
To specify a default debug script
In Solution Explorer, expand the Test Scripts folder for the project that you want to configure.
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