Walks you through the process of using the
SQL Server Object Explorer to debug and to execute the LookupEMP stored procedure.
Configure the debugger
- In Visual Studio, start the
SQL Server Object Explorer.
- On the
SQL Server Object Explorer, click
Add SQL Server
.
- On the
History tab under
Recent Connections, select
SQLCLR_Test; then click
Connect.
Note: If Microsoft SQL Server prompts you with an
Attach Security Warning, please click
Attach to clear the prompt.
- On the
SQL Server Object Explorer, right-click your SQL Server instance, represented by a dot followed by your local server information in parentheses, and
check
Application Debugging and
Allow SQL/CLR Debugging.
Note: If a prompt appears, click
Yes to enable SQL CLR debugging.
Run the SQL/CLR debugger
- On the
SQL Server Object Explorer, expand the entry for your local SQL Server.
- Expand
Databases > SQLCLR_Test > Programmability > Stored Procedures.
- When the
SQL Server Object Explorer has refreshed, right-click the
dbo.LookupEMP stored procedure and select
Debug Procedure.
- In the
Value field for the
@lkEMPNO name, type
000020.
- Check the box in the
Null column for the
@lkFIRSTNME and
@lkLASTNAME names, and then click
OK.
Visual Studio connects to your SQL Server instance, creates a test SQL script, calls your stored procedure, and runs the
debugger with your cursor on the
USE [SQLCLR_Test] statement of the test SQL script.
- Use the Visual Studio debugger to step through the lines of code in your stored procedure, examining variables and values,
etc.
The
Data Tools window on the
Results tab displays information returned from the debugger.
- To exit the debugger, click
Debug >
Stop Debugging.
Execute the LookupEMP stored procedure
You can execute the stored procedure from the
SQL Server Object Explorer. By providing required input values, you can see the output that results from the stored procedure call.
- From the
SQL Server Object Explorer, right-click the
dbo.LookupEMP stored procedure, and select
Execute Procedure.
- If not already set, type
000020 into the
Value field for the
@lkEMPNO name, and check
Null for the other two names.
- Click
OK to execute the stored procedure.
- View the results on the
Results tab:
- Close the
SQL Server Object Explorer.