Question : Help, my query using opendatasource, a where clause and option(robust plan) fails. What am I doing wrong

Hi experts,

I'm trying to retrieve the syscomment records for any given sproc from another server in order to compare it with the one on a second server and update the second one if neccessary.
Unfortunately the records in syscomment are pretty much over the maximum allowed length for a record since they contain the query both in varbinary(8000) and nvarchar(4000) format and I need both fields for the update.

Using a query without a where-clause, everything is OK and I get no errors:
select number,colid,B.status,ctext,texttype,language,encrypted,compressed,text
from opendatasource('sqloledb','data source=meatdev01;integrated security=sspi').dbmeatadres.dbo.sysobjects A
inner join opendatasource('sqloledb','data source=meatdev01;integrated security=sspi').dbmeatadres.dbo.syscomments B
on A.id = B.id
option (robust plan)

But when I add a where clause I get the error "Cannot create a worktable row larger than allowable maximum. Resubmit your query with the ROBUST PLAN hint.":
select number,colid,B.status,ctext,texttype,language,encrypted,compressed,text
from opendatasource('sqloledb','data source=meatdev01;integrated security=sspi').dbmeatadres.dbo.sysobjects A
inner join opendatasource('sqloledb','data source=meatdev01;integrated security=sspi').dbmeatadres.dbo.syscomments B
on A.id = B.id where A.name = 'fn_pcre_match'
option (robust plan)

What am I doing wrong?

Answer : Help, my query using opendatasource, a where clause and option(robust plan) fails. What am I doing wrong

let me suggest this:

SELECT a.*
FROM OPENROWSET('MSDASQL',
   'PROVIDER=SLOLEDB;SERVER=meatdev01;DATABASE=dbmeatadres;',
   'select number,colid,B.status,ctext,texttype,language,encrypted,compressed,text
from dbo.sysobjects A
inner join dbo.syscomments B
on A.id = B.id
and A.name = ''fn_pcre_match''
 ') AS a
ORDER BY au_lname, au_fname
Random Solutions  
 
programming4us programming4us