Hello Experts,
I am trying to make a function to get the rowcount of a table, where the table name is the argument into the function.
SELECT @SQLSENT = 'SELECT COUNT(*) FROM ' + @AS_TABLENAME + ';'
EXECUTE sp_executesql @SQLSENT, N'@LL_COUNT INTEGER OUTPUT', @LL_COUNT OUTPUT
RETURN @LL_COUNT
Trying to run this I get the following error message:
Server: Msg 557, Level 16, State 2, Procedure FMIS_GETTABLECOUNT, Line 12
Only functions and extended stored procedures can be executed from within a function.
Can anyone help me out with this one?
Thanks for any advice.

I am trying to make a function to get the rowcount of a table, where the table name is the argument into the function.
SELECT @SQLSENT = 'SELECT COUNT(*) FROM ' + @AS_TABLENAME + ';'
EXECUTE sp_executesql @SQLSENT, N'@LL_COUNT INTEGER OUTPUT', @LL_COUNT OUTPUT
RETURN @LL_COUNT
Trying to run this I get the following error message:
Server: Msg 557, Level 16, State 2, Procedure FMIS_GETTABLECOUNT, Line 12
Only functions and extended stored procedures can be executed from within a function.
Can anyone help me out with this one?
Thanks for any advice.