简体   繁体   中英

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.

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM