SQL Server 2005: Internal Query Processor Error:

Posted by Geetha on Stack Overflow See other posts from Stack Overflow or by Geetha
Published on 2009-10-06T06:48:00Z Indexed on 2010/03/27 21:03 UTC
Read the original article Hit count: 169

Filed under:
|
|

I am trying to execute this following procedure in SQL Server 2005. I was able to execute this in my development server and when i tried to use this in the Live Server I am getting an Error "Internal Query Processor Error: The query processor could not produce a query plan. For more information, contact Customer Support Services". am using the same Database and the same format. when we searched in the web it shows some fixes to be used in sql server 2005 to avoid this error but my DBA has confirmed that all the patches are updated in our server. can anyone give me some clue on this.

Query:

create Procedure [dbo].[sample_Select] 
@ID as varchar(40)   
as  
Declare @Execstring as varchar(1000)
set @Execstring =  
'   
Declare @MID as varchar(40) 
Set @MID =  '''+@ID+'''  
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 @Execstring=@Execstring+ 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 =@Execstring +')) as pivotTable'   
exec (@Execstring)

© Stack Overflow or respective owner

Related posts about sql-server

Related posts about query