Fastest way to move XML document into and back out of CLR function



Fastest way to move XML document into and back out of CLR function

In SQL Server 2005 and Visual Studio 2005, what is the fastest way to pass
an xml data type variable into a C# CLR function and retrieve it back out of
the C# CLR function when the C# CLR function is done modifying it?

I tried this but get deployment error becuase SQLServer2005/CLR dotn support

public partial class UserDefinedFunctions
public static int InsertSomeNode(System.Xml.XmlDocument pDoc)
return 1;

thorws error:
Error 1 Column, parameter, or variable #1: Cannot find data type
XmlDocument. InsertSomeNode



Nicholas Paldino [.NET/C# MVP]

Well, the fastest way to move an XML document into and out of a CLR
function is to just send an XmlDocument. However, SQL Server isn't going to
let you do that outright.

Rather, you want to declare the pDoc parameter as a string, and then
parse the document inside the CLR procedure.

You might be able to get away with declaring the stored procedure as an
output parameter, but I don't know if the xml type can be passed in then.
It should be easy enough to figure it out with a simple example.

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question