Tuesday, 9 September 2008

T-SQL EXEC and Table-valued Functions

So I've spent all day building an SQL Server table-valued function, which happens to include a bit of dynamic SQL called by 'exec sp_executesql'. 5.30pm comes around, I think great, I'll be able to test this baby before I go home.

Run the project - bam.

---------------------------
Appointment Stats
---------------------------
Only functions and extended stored procedures can be executed from within a function.
---------------------------
OK   
---------------------------

Turns out you can't use EXEC from within a table-valued function. Time for a rethink...

0 comments: