venerdì 22 luglio 2011

Generare una tabella contatore utilizzando le Common Table Expressions (CTE)

--define start and end limits
Declare @start int, @end int
Select @start=1, @end=100

With NumberSequence( Number ) as
(
    Select @start as Number
        union all
    Select Number + 1
        from NumberSequence
        where Number < @end
)

Select *
From NumberSequence
Option (MaxRecursion 100)

Nessun commento:

Posta un commento