可以。但最大的層數為32層。
/*N!的實現*/Create   Proc TestNest @Val int
As
   Declare @Cnt int
   IF @Val>12
       BEGIN
              RAISERROR('超出范圍',15,1)
              RETURN 0
      END
   IF @Val=1 OR @Val=0
       RETURN 1
  ELSE
     BEGIN
            SET @Val=@Val-1
            Exec @cnt=TestNest  @Val
            set @cnt=@cnt* (@Val+1)
           RETURN @cnt
     ENDGO
Declare @p int
EXEC @p=TestNest 13
Print @p