Question

I'm doing some work on a linked SQL Server 2000 via SQL Server 2008 Express on my local workstation. SQL2000 is sitting on a very impressive rack with a lot resource available, so I want to make use of that whereever possible.

I'm dealing with XML strings stored in TEXT format on the remote table. My original query contained a subquery within it as follows:

SELECT Id, FolderId, CAST(REPLACE(CAST(Content AS VARCHAR(MAX)) AS XML), 'encoding="utf-16"', '') AS ContentXML
FROM [LinkedServer].[UPLSalesP].[dbo].[RSSDocument]

However I can only presume that the majority of the subquery is being executed on my workstation rather than the rack, as neither VARCHAR(MAX) or XML datatypes are available in SQL2000. After 10 hours of executing the above query on 2.5 million rows, it suffered memory failure and aborted.

Is my presumption on where its being executed correct? If I changed it to the following:

SELECT Id, FolderId, REPLACE(CAST(Content AS VARCHAR(8000)), 'encoding="utf-16"', '') AS ContentXML
FROM [LinkedServer].[UPLSalesP].[dbo].[RSSDocument]

Would the subquery execute remotely first? Is it possible to get any efficiency out of doing it this way and then converting to XML after in my local 2008 Express instance?

No correct solution

OTHER TIPS

Try using OPENQUERY instead. This will execute the select command on the linked server, and pass the results back through. It would look something like this:

SELECT Id, FolderId, ContentXML
FROM OPENQUERY( LinkedServerName, 'SELECT Id, FolderId, CAST(REPLACE(CAST(Content AS VARCHAR(MAX)) AS XML), 'encoding="utf-16"', '')
AS ContentXML
FROM [dbo].[RSSDocument]')

(If I'm wrong be gentle, it's my first answer!)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top