Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 returning a recordset of a select in a function

Author  Topic 

pelegk2
Aged Yak Warrior

723 Posts

Posted - 2006-02-13 : 01:55:16
i have a select which i build as a string
and execute the string with
[CODE]Exec(strSql)[/CODE]
how do i return the result from the function and what is the return value that i should (or dont have to)define at the begining of the function?

thnaks in advance
peleg

Israel -the best place to live in aftr heaven 9but no one wan't to go there so fast -:)

shallu1_gupta
Constraint Violating Yak Guru

394 Posts

Posted - 2006-02-13 : 02:16:10
Hi,
Its better to use a stored procedure since you cannot insert the output of an exec statement in a table variable.
you can store the output of your exec statement in a temp table in an SP and use

select <column names >
from <temptable>

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-02-13 : 03:11:42
You cant use Dynamic SQL inside a Function, the correct way is to use Stored Procedure as suggested. Without dynamic SQL, you can have a function that returns data as Table

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -