简体   繁体   English

存储的proc失败,出现SQL错误3621,在ssms中运行良好,并且如果删除并重新创建

[英]Stored proc failing with SQL error 3621, runs fine in ssms and if dropped and recreated

I have a stored proc that is called by a .net application and passes an xml parameter - this is then shredded and forms the WHERE section of the query. 我有一个存储的proc,由.net应用程序调用并传递一个xml参数-然后将其切碎并形成查询的WHERE部分。

So in my query, I look for records with a documentType matching that contained in the XML. 因此,在我的查询中,我将查找具有XML中包含的documentType匹配的记录。 The table contains many more records with a documentType of C than P. 该表包含的文档类型为C的记录多于P。

The query will run fine for a number of week, regardless of if the XML contains P or C for documentType. 无论XML是否为documentType包含P或C,查询都可以在一周内正常运行。 Then it stops working for documentType C. 然后,它停止为documentType C工作。

I can run both queries from SSMS with no errors (using profiler to capture the exact call that was made). 我可以在没有错误的情况下从SSMS运行两个查询(使用探查器捕获进行的确切调用)。 Profiler shows that when run from the application, the documentType C query starts a statement then finishes before the statement ends, and before completing the outstanding steps of the query. Profiler显示,从应用程序运行时,documentType C查询开始一条语句,然后在该语句结束之前和完成查询的未完成步骤之前完成。

I ran another profiler session to capture all errors and warnings. 我运行了另一个探查器会话以捕获所有错误和警告。 All I can see is error 3621 - The statement has been terminated. 我只能看到错误3621-该语句已终止。 There are no other errors relating to this spid, the only other things to be picked up were warnings changing database context. 没有其他与此错误相关的错误,唯一需要注意的其他事情是更改数据库上下文的警告。

I've checked the SQL logs and extended events and can find nothing. 我检查了SQL日志和扩展事件,什么都找不到。 I don't think the query relates to the data content as it runs in SSMS without problems - I've also checked the range values for other fields in the WHERE clause and nothing unusual or untoward there. 我认为查询与数据内容无关,因为它在SSMS中运行没有问题-我还检查了WHERE子句中其他字段的范围值,那里没有异常或不正常的情况。 I also know that if I drop and recreate the procedure (ie exact same code) the problem will be fixed. 我也知道,如果我删除并重新创建该过程(即完全相同的代码),该问题将得到解决。

Does anyone know how I can trace the error that is causing the 3261 failure? 有谁知道我如何追踪导致3261故障的错误? Profiling does not pick this up. 分析不会进行此操作。

In some situations, SQL Server raises two error messages, one is the actual error message saying exactly what is happening and the other one is 3621 which says The statement has been terminated . 在某些情况下,SQL Server会引发两条错误消息,一条是实际错误消息,准确说明正在发生的事情,另一条错误消息是3621,表明The statement has been terminated

Sometimes the first message get lost specially when you are calling an SQL query or object from a script. 有时,当您从脚本中调用SQL查询或对象时,第一条消息会特别丢失。

I suggest you to go through each of your SQL statement and run them individually. 我建议您遍历每个SQL语句并分别运行它们。

Another guess is you have a timeout error on your client side. 另一个猜测是您的客户端出现超时错误。 If you have Attention event on your SQL Server trace, you can follow the timeout error messages. 如果您的SQL Server跟踪上有Attention event ,则可以遵循超时错误消息。

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

相关问题 在VB.net中存储的proc超时,但在SSMS中快速运行 - Stored proc timeout in VB.net but runs quickly in SSMS 在 SSMS 中使用存储过程时使用批量插入到 Azure SQL DB 时出错 - Error when using bulk insert into Azure SQL DB when using stored proc in SSMS 使用 SSMS 时,SQL 还原失败并出现错误 - SQL restore is failing with an error when using SSMS 在SSMS中运行良好的SQL查询在ASP.NET中运行非常慢 - SQL Query that runs fine in SSMS runs very slow in ASP.NET 存储过程的结果与 SSMS 查询不同 - Result from Stored proc different to SSMS Query 存储过程给出了“无法找到对象……”错误,但在SSMS中工作正常 - Stored Procedure gives Cannot find object… error in SSIS, but works fine in SSMS 我在存储过程的脚本 sql 中收到返回值错误 - i get an error with return value in my script sql of stored proc 从DotNet执行存储过程需要很长时间,但在SSMS中它是立即的 - Executing stored proc from DotNet takes very long but in SSMS it is immediate 通过 SSMS 命令调用存储过程并传递带空格的字符串 - Calling a stored proc via SSMS command and passing strings with spaces 存储过程通过SSIS(通过SQL代理作业)与通过SSMS手动执行相比,运行速度降低24,000% - Stored Procedure Runs 24,000% slower via SSIS (via SQL Agent job) vs Manual Execution via SSMS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM