sp_helptext 输出被 ADO.NET 删除?
我正在使用此处描述的工具来清理一些来自我们的开发数据库。我遇到了一个奇怪的问题,但找不到原因。
对于某些存储过程,GetProcedureText 方法(l:47,Validator.cs)无法返回过程文本,导致程序出现意外行为。调试并单步执行 GetProcedureText 时,可以清楚地看到,通过调用 SqlCommand 上的 ExecuteReader 返回的 SqlDataReader 不包含结果集。问题是为什么......
从 SSMS 运行 exec sp_helptext
USE [IL_Party_DB]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[DeathCause_SelectByDeathCauseCode]
@deathCauseCode [varchar](15)
AS
SELECT
death_cause_code,
description
FROM ilpr_Death_Cause
WHERE
death_cause_code = @deathCauseCode
我正在使用 SQL Server 2005。有什么想法吗?
I'm using the tool described here to clean up some cruft from our development DBs. I've encountered an odd issue with it and can't find the cause.
For certain stored procedures, the GetProcedureText method (l:47, Validator.cs) fails to return the proc text, causing the program to behave unexpectedly. When debugging and stepping into GetProcedureText it becomes clear that the SqlDataReader returned by the call to ExecuteReader on the SqlCommand does not contain a result set. The question is why..
Running exec sp_helptext <proc name>
from SSMS does return the proc text as expected. The problem occurs with the same procs every time. Below is one of the procs exhibiting this issue, though the problem does seem to be with ADO.NET rather than SQL Server.
USE [IL_Party_DB]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[DeathCause_SelectByDeathCauseCode]
@deathCauseCode [varchar](15)
AS
SELECT
death_cause_code,
description
FROM ilpr_Death_Cause
WHERE
death_cause_code = @deathCauseCode
I'm using SQL Server 2005. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我遇到了同样的问题。就我而言,它似乎是在对象的 SQL 中出现错误(例如重命名的列或表)时发生的。它将返回一个空结果,然后所有后续对象都将返回一个空结果。我必须为每个数据库对象创建一个新的 SqlConnection 才能使其正常工作。不确定根本原因是什么,但这对我有用......
I ran into the same problem. In my case, it seemed to occur when there was an error in the object's SQL, such as a renamed column or table. It would return an empty result, then all subsequent objects would return an empty result. I had to create a new SqlConnection for each database object to get it to work properly. Not sure what the underlying cause is, but this worked for me...