Stored procedure

Why Stored procedure is not used inside the function.

Functions don't allow side effects to objects that are not local to the function itself.

An easy way to think of the "no side affecting objects" thing is this... You can't use anything that requires the use of the EXEC command... So no stored procs and no dynamic sql.