Cannot debug a stored procedure in Visual Studio 2005 or in Visual Studio .NET after you rename SQL Server (817253)



The information in this article applies to:

  • Microsoft Visual Studio 2005 Standard Edition
  • Microsoft Visual Studio 2005 Professional Edition
  • Microsoft Visual Studio .NET (2003), Professional Edition
  • Microsoft Visual Studio .NET (2003), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2003), Enterprise Developer Edition
  • Microsoft Visual Studio .NET (2003), Academic Edition
  • Microsoft Visual Studio .NET (2002), Professional Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Developer Edition
  • Microsoft Visual Studio .NET (2002), Academic Edition

SYMPTOMS

When you rename your installation running Microsoft SQL Server a different name from your host server, you cannot step into the SQL stored procedure to debug in the Visual Studio 2005 or Visual Studio .NET development environment. T-SQL debugger silently executes the stored procedure and then does not stop at the breakpoint in the stored procedure.

CAUSE

During installation, SQL Server stores the server name in a system table entry that the debugger uses. When you modify the SQL Server name, the system table entry updates the server name. For T-SQL debugging to work correctly in Visual Studio 2005 or in Visual Studio .NET, the computer name and the SQL Server installation name must match. If you rename the SQL Server installation, the computer names do not match the SQL Server installation name, and then T-SQL debugging fails.

STATUS

This behavior is by design.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Verify that T-SQL debugging works in Visual Studio 2005 or in Visual Studio .NET.
  2. Run the following command in Query Analyzer to rename your SQL Server:
    sp_dropserver 'OldServerName'
    go
    sp_addserver 'NewServerName','local'
    go
    
  3. Stop and then restart SQL Server to update the @@servername global variable with the correct server name.
  4. To verify that the server name is modified, use Query Analyzer to run the following command:
    SELECT @@servername
    
  5. Delete and then re-create your data connection in Server Explorer.
  6. Open the stored procedure in Server Explorer, and then set a breakpoint.
  7. When you try to step into the stored procedure, notice that T-SQL debugger ignores the breakpoint that you set.

REFERENCES

For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

317241 PRB: Renaming a Host Computer for SQL Server Causes Stored Procedure Debug to Fail



Modification Type:MajorLast Reviewed:2/24/2006
Keywords:kbvs2005applies kbvs2005swept kbDebug kbTSQL kbStoredProc kbServer kbprb KB817253 kbAudDeveloper