Subroutines in TSQL
Posted on 1998-07-08
Is there a way to define a sub-routine in a stored procedure so that I could invoke it multiple times when executing my stored procedure. For example, I need to perform a set of commands several times but using different variables. I want to define this routine as a procedure with parameters and call it within my stored procedure. Creating this subroutine as a stored procedure by itself is not worth it, because it is very specific to the stored procedure I'm writing.
I looked in the TSQL manual and couldn't find any reference of defining a local procedure the way it is done in most of the languages I know.