• On top of the plagiarism issue (as yet unproven -"reema" may be a pseudonym of Arthur Fuller, although that seems unlikely) and the use of technical terms (recursive, recursion) of computer science and mathematics in a sense that they don't have in those arts/sciences (despite SQL Server certainly being something to do with computation) the explanation is pretty terrible.

    Since SQL Server doesn't do multi-statement optimisation, it certainly doesn't do optimisation of tail-recursion; so quite clearly T-SQL procs that call themselves to implement tail-recursion should never be written since they will be gloriously inefficient - so this implementation of factorial is a fine example of something that should never be done. In addition, T-SQL doesn't actually support recursion except in a restricted form, with a restriction of 32 on nesting level ( and although this does no harm to the factorial function, which of course blows up at 21 even if it uses bigint for its result, that restriction should certainly have been mentioned.

    So in general a T-SQL procedure calling itself should be used only for functions which are not easily converted to tail-recursive form (and hence to iterative form) and where it is assured that the necessary nesting level does not excede the T-SQL limit or the procedure contains tests to detect when the nesting level is getting to high and can do something useful/intelligent to avoid this (instead of just failing with the vanilla error message provided by the system). A discussion of "recursive" stored procedures which doesn't point this out is a bit like rat poison in a jam-jar without a warning label.

    Note: in mathematics, in computer science, in formal logic, and in computation theory "recursive" means "able to be computed by using a Turing machine" or, equivalently, "able to be computed by using lambda calculus"; so every possible stored procedure is recursive, whether it calls itself or not. Use of the term to mean "calls itself" is fine in other contexts, but really irritating in the context of computing, as in this question and explanation. Generally it is believed that "recursive" is the same as "in principle a human being could compute it if supplied with enough paper and pencils and detailed instructions by following the instructions exactly and mechanically with no excercise of intelligence or intuition" (that is "Church's Thesis" or "Turing's Thesis" or "The Church-Turing Thesis", perhaps the most important idea in the theory of computation and certainly the most horribly misinterpreted - a decent explanation can be found here[/url]).

    Tom