1

I have an existing CLR that uses XST to shred and validate XML passed in. I want to capture the data points (don't care about the XML itself) into a table that can be directly inserted into a database table. So I'd call my CLR stored proc and it would return 4 columns with hundreds or rows and I could simply do an

insert into EXISTINGtable 
select * from TableReturnedFromCLRspCAll

It doesn't have to be an SP it could be a UDF ... my real question is how do I get CLR to return a table. I need to be able to pass in the table definition as well. So for the table that is being returned by the CLR ... I would like to have the 4 column names and types be part of the call to the CLR as variables.

If someone can help me with this I would be most grateful and very impressed because I've asked around to some very seasoned guys and they all throw up their hands when I get to the CLR having a dynamic table AND/OR CLR returning a table at all.

Thanks!

1 Answer 1

1

From MSDN http://msdn.microsoft.com/en-us/library/ms131094.aspx

Returning Tabular Results

To send the results of a query directly to the client, use one of the overloads of the Execute method on the SqlPipe object. This is the most efficient way to return results to the client, since the data is transferred to the network buffers without being copied into managed memory.

I haven't tried it from a stored procedure, but I have returned a table from a CLR UDF using the following example. http://msdn.microsoft.com/en-us/library/ms131103.aspx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.