2009-10-06 95 views
0

我想在SQL Server 2005中执行此过程。我能够在我的开发服务器中执行此操作,并且当我尝试在Live Server中使用此操作时,错误“内部查询处理器错误:查询处理器无法生成查询计划。有关更多信息,请联系客户支持服务”。我正在使用相同的数据库和相同的格式。当我们在网上搜索时,它显示了一些修复程序在sql server 2005中使用,以避免这个错误,但我的DBA已经确认所有修补程序都在我们的服务器中更新。任何人都可以给我一些线索。SQL Server 2005:内部查询处理器错误:

查询:

create Procedure [dbo].[sample_Select] 
@ID as varchar(40) 
as 
Declare @Execstring as varchar(1000) 
set @Execstring = 
' 
Declare @MID as varchar(40) 
Set @MID = '''[email protected]+''' 
select * from ( 
select t1.field1, t1.field2 AS field2 , t1.field3 AS field3 , L.field1 AS field1 , L. field2 AS field2 from table1 AS t1 
INNER JOIN MasterTable AS L ON L. field1 = t1. field2  
where t1. field2 LIKE @MID 
) as DataTable 
PIVOT 
( 
Count(field2) 
FOR field3 
IN (' 
Select @[email protected]+ L.field2 +',' FROM MasterTable AS L inner join 
table1 AS t1 ON t1.field1= L.field2 Where t1.field2 LIKE @ID 
set @Execstring = stuff(@Execstring, len(@Execstring), 1, '') 
set @Execstring [email protected] +')) as pivotTable' 
exec (@Execstring) 
+1

尝试拨打MS客户服务。如果这是一个错误,支持案例应该是免费的。 – Lucero 2009-10-06 06:56:01

+0

您的数据库管理员确认您的搜索结果中提到的修补程序是否已安装,或者他是否只确认数据库处于最高修补程序级别(没有Microsoft Update的新修补程序)?它可能是一个非官方的补丁,尚未发布。您必须联系Microsoft支持才能获得这些支持。 – 2009-10-06 08:04:30

+0

可能值得做一个Print @Execstring而不是执行它来检查生产服务器上的输出是什么,并且将它匹配到dev服务器以防万一。 – Andrew 2009-10-06 10:36:48

回答

0

你基本上遇到在查询优化和错误只其他解决方法(假设疗法修复程序没有工作)是重写查询,以避免错误。例如,可以通过将子查询作为连接来完成此操作。即使微软解决了这个问题,为什么会出现这种错误有很多原因。