Friday, February 10, 2012

Calling T SQL stored proc from CLR stored proc

I would like to know if the following is possible/permissible:

myCLRstoredproc (or some C# stored proc)

{

//call some T SQL stored procedure spSQL and get the result set here to work with

INSERT INTO #tmpCLR EXECUTE spSQL

}

spSQL

(

INSERT INTO #tmpABC EXECUTE spSQL2

)

spSQL2

(

// some other t-sql stored proc

)

Can we do that? I know that doing this in SQL server would throw (nested EXECUTE not allowed). I dont want to go re-writing the spSQL in C# again, I just want to get whatever spSQL returns and then work with the result set to do row-level computations, thereby avoiding to use cursors in spSQL.

Why bother with the temp-tables, why not call directly into spSQL2 from your CLR proc?

Niels
|||

Well, the spSQL is doing a lot more than just calling spSQL2. Besides, I can't touch spSQL and spSQL2. I know it looks ugly, but it seems this might be what I need to do in my current problem.

Just let me know if it is possible or the CLR will throw the nested execution of stored procedure error?

Thanks.

No comments:

Post a Comment