|
Posted by Erland Sommarskog on 08/21/06 08:05
Ed Murphy (emurphy42@socal.rr.com) writes:
> What are the pros and cons of relying on such a table vs. using a
> WHILE loop? Based on Rob's context of student registrations, let's
> assume we're talking about a maximum of 300 iterations per row in
> the original tblDates table.
The one risk with a table of numbers is that if you run of numbers, you
will get an incorrect result. That is one reason why I'm reluctant to
use it, if there are alternative solutions. But for a case like this,
when you need to fill up a space, a table of numbers - or dates - is what
you need.
A loop is more complex to program, and easier go wrong. And as a generic
solution, you face scalability problems.
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
Navigation:
[Reply to this message]
|