出现错误,“您的SQL语句的某些部分嵌套得太深"仅在某些服务器上 [英] Got error, "Some part of your SQL statement is nested too deeply" only on some servers

查看:127
本文介绍了出现错误,“您的SQL语句的某些部分嵌套得太深"仅在某些服务器上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们将Entity Framework更新为6.1.3,此后在某些服务器上(非常是运行单元测试的服务器),我们现在得到了例外:

We updated Entity Framework to 6.1.3, since then on some servers (sadly the ones that run the unit tests), we get now the exception:

System.Data.SqlClient.SqlException: SQL语句的某些部分嵌套得太深.重写查询或将其分解为较小的查询.

System.Data.SqlClient.SqlException: Some part of your SQL statement is nested too deeply. Rewrite the query or break it up into smaller queries.

在一些嵌套程度不高的EF查询中.

on some EF queries that aren't that deep nested.

当我们更改EF版本时,我们进行了其他更改,但是这些似乎都没有影响单元测试.使用这些查询的服务完全没有改变.

When we changed EF versions we made other changes, but none of these seem to have influenced the unit tests. The service that uses these queries wasn't changed at all.

我没有在环境中找到此异常的任何条件,而且我有点不敢相信由于EF更新而发生了这种情况.还有其他可能导致此异常的影响吗?

I didn't find any condition in the environment for this exception, and I kinda can't believe it happens because of the EF update. Are there more influences that could cause this exception?

我刚刚提取查询,并在其中一台发生故障的服务器上运行了该查询,该服务器足够有趣.所以我想必须是EF吗?

I just extracted the query and ran it on one of the failing servers, which is working funnily enough. So I guess it has to be EF?

推荐答案

您的SQL语句的某些部分嵌套得太深.重写查询或将其分解为较小的查询.

Some part of your SQL statement is nested too deeply. Rewrite the query or break it up into smaller queries.

此错误消息是由 SQL Server 生成的.它表示一个SQL查询 无法分析,因为它太复杂了.您使用的新版本的 Entity Framework 可能具有与以前不同的优化器,该优化器将生成比以前更多的嵌套SQL查询,这就是现在出现此错误消息的原因.

This error message is generated by SQL Server. It indicates that a SQL query can't be analyzed because it is too complex. The new version of Entity Framework you used may have a different optimizer that will generate a more nested SQL query than before, this is why you have this error message now.

在某些版本的SQL Server上也可能会出现此错误消息.如果您的SQL Server没有相同的版本,则可以解释为什么只在某些配置下重现它.您可以在以下连接错误中找到有关此行为的更多信息: SQL语句嵌套得太深了

This error message may also happens on some version of SQL Server. If your SQL Servers don't have the same version, it could explain why you reproduce it only on some configuration. You can find more information on this behavior in this connect bug : SQL statement is nested too deeply

此问题已通过 SQL Server 2012 SP2 SQL Server 2014 SP1

这篇关于出现错误,“您的SQL语句的某些部分嵌套得太深"仅在某些服务器上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆