Michael
Michael

Reputation: 13616

How to call a function from SQL stored procedure

I have function that have been colled in stored procedure. The function returns a table and have to fill another table. Maybe this queistion might be seems a little naive but im a newer in T-SQL. Thank you in advance.

Upvotes: 0

Views: 5677

Answers (1)

Charles Bretana
Charles Bretana

Reputation: 146499

Just use the function as though it was a table. You can:

Select * From dbo.MyFunction()

If you need to pass a value from the outer query into the UDF, use Cross Apply

like this:

 Select * From sys.dm_exec_requests ser 
 Cross Apply sys.dm_exec_sql_text(ser.sql_handle)

Upvotes: 1

Related Questions