• If you just want to query the stored procedure results, leave the function alone, way too complicated.

    You could set up a loopback linked server (ilnked server pointing to the server itself) and the run something like:

    SELECT theColumnsYouNeed

    FROM OPENQUERY(LOOPBACK, 'EXEC dbo.usp_GetAnalysis @mode = ''mode'' , @group = ''group'' ')

    As I said, don't try to put it in the function, because it would simply ignore any data modification instruction contained in the stored procedure, WITHOUT raising any error. It's surprising, but it's so. Functions are not allowed to modify data.

    Hope this helps.

    Gianluca

    -- Gianluca Sartori