In this example master..spt_values is used as a
tally table. When you filter
where type="p" you get a result set with a sequence of numbers starting from 0 to over 2000. A tally table helps to solve several TSQL problems in a SET based fashion. So it is a common practice to keep a tally-table or calendar-table in most databases.
When posting an example in a public forum, most people use master..spt_values to demonstrate the concept if the example needs a tally table. It allows some one reading the post to copy the code and test it right-away (without going through the tally table creation process first).
commented on Jul 22 2011 10:19PM