Resource Page Description This TVF generates a contiguous sequence of integers. Useful for generating test data, populating calendars, etc.
This is a Table-Valued User Defined Function to generate all the integers between two endpoints. It's surprisingly fast, easilly beating my best effors at writing a CLR UDF to do this. Use it like this select Seq.Value from Utils.Sequence(1,1000) seq or select dateadd(d,Seq.Value,'2000-01-01') d from Utils.Sequence(1,2000) seq to generate a calendar. NB: this is not a replacement for IDENTITY columns or a oracle sequence work-alike. NB2: This query uses a stack of Common Table Expressions to generate the numbers, and the original implementation is credit to MVP's Steve Kass and Itzik Ben-Gan. David
|