简体   繁体   English

调试MS SQL存储过程

[英]Debugging MS SQL Stored Procedure

I have a problem getting Stored Procedure debugging to work in Visual Studio 2008: When I start debugging, I get these success messages in the output window, however the actual stored procedure windows does not show up. 我在Stored Procedure调试中使用Visual Studio 2008时遇到问题:当我开始调试时,我在输出窗口中获得这些成功消息,但是实际的存储过程窗口没有显示出来。

Auto-attach to process '[1640] [SQL] stagsql' on machine 'stagsql' succeeded.
The thread 'stagsql [67]' (0xf80) has exited with code 0 (0x0).
The thread 'stagsql [67]' (0xf80) has exited with code 0 (0x0).
The thread 'stagsql [69]' (0x908) has exited with code 0 (0x0).
The thread 'stagsql [69]' (0x908) has exited with code 0 (0x0).
The thread 'stagsql [69]' (0x908) has exited with code 0 (0x0).
The thread 'stagsql [69]' (0x908) has exited with code 0 (0x0).
Running [dbo].[uspCGetXYZ] ( @nLieferantId = 161616, @nStrukturId = -1, @nPageIndex = 1, @nPageSize = 16, @sSortColumn = arLangname, @nSortAscending = 1 ).

Visual Studio gets into 'debug mode' but the procedure does not show up at all. Visual Studio进入“调试模式”但该过程根本没有显示。

The steps I did: 我做的步骤:

  • Enabled SQL debugging in the project settings 在项目设置中启用SQL调试
  • Opened the SQL Connection in Server Explorer 在服务器资源管理器中打开SQL连接
  • Enabled CLR/SQL debuggin on the connection 在连接上启用CLR / SQL调试程序
  • Right-click on the procedure and selected "step into stored procedure" 右键单击该过程并选择“步入存储过程”

Alternatively I tried to open up the procedure and set a break-point there, it didn't help. 或者,我试图打开程序并在那里设置一个断点,但没有帮助。

Any ideas? 有任何想法吗? As said, the connection is there but Visual Studio is not capable of opening the procedure code. 如上所述,连接存在,但Visual Studio无法打开过程代码。

By any chance, do you have " Display Actual Execution Plan " selected? 您是否有机会选择“ 显示实际执行计划 ”? I've found that debugging won't run if you have that button clicked, though I can't for the life of me figure out why that would be the case. 我发现如果你点击了那个按钮就不会运行调试,虽然我不能在我的生活中弄明白为什么会出现这种情况。

I haven't submitted a bug on Connect, but would be happy to upvote one if somebody knows about it. 我没有提交关于Connect的错误,但是如果有人知道的话,我很乐意提出一个错误。

Can you see the code behind that stored procedure? 你能看到该存储过程背后的代码吗? If it is saved "WITH ENCRYPTION", you may not be able to see the code and then you will need the original source code for the proc to debug it. 如果它保存为“WITH ENCRYPTION”,您可能无法看到代码,然后您将需要proc的原始源代码来调试它。

Is the solution a database solution? 解决方案是数据库解决方案吗? Did you go New->Solution->Other->Database? 你去New-> Solution-> Other-> Database?

Once you create a database solution then setup your connection preferences you should be able to use the server explorer to edit and step-into the stored procedure. 创建数据库解决方案然后设置连接首选项后,您应该能够使用服务器资源管理器进行编辑并逐步进入存储过程。 Please verify this still causes the issue? 请验证这仍然导致问题?

Are you using an express edition? 你在使用快递版吗?

I don't think ou can put breakpoints into it like you could in a normal VS application. 我不认为你可以像在正常的VS应用程序中那样将断点放入其中。

However you can create a temp table for logging, and on each line add a new entry into that temp table. 但是,您可以创建临时表以进行日志记录,并在每行上向该临时表中添加一个新条目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM