How To pass a resultset to a function

Hi,

I have a problem passing the resultset of a query to a function.

so I started like this:

DECLARE @idoc asint,@MyResultsetas?,@StartPathasnvarchar(50);

set @StartPath ='nodes/node'

EXECsp_xml_preparedocument @idocoutput,@XML_IN

set@MyResultset =(select*fromOPENXML(@idoc,@startpath,2))

select fn_myfunction(@MyResultset);-- get the recursive path for example

but this don't work.

Do i have to use a temporary table or is there any way to do it with parameters?

Thanks in advance

Raimund

[1814 byte] By [Raimund] at [2008-1-10]
# 1

In SQL Server 2000/2005 you could indeed work with a temporary table like you suggest.

In SQL Server 2008 you can use table valued parameters but unfortunately it is a bit early for that.

WesleyB

Visit my SQL Server weblog @ http://dis4ea.blogspot.com

WesleyB at 2007-10-3 > top of Msdn Tech,SQL Server,Transact-SQL...
# 2

Hi!

You can also convert your result set to an xml ("for xml"),

send it to function, and revert it to an result set

BjornD.Jensen at 2007-10-3 > top of Msdn Tech,SQL Server,Transact-SQL...
# 3

Thank you for your contributions i think I'll use a temporary table until SQL-Server 2008 is available.

Best Regards

Raimund

Raimund at 2007-10-3 > top of Msdn Tech,SQL Server,Transact-SQL...

SQL Server

Site Classified