Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 query doubt

Author  Topic 

spock
Starting Member

35 Posts

Posted - 2002-01-16 : 08:48:05
Hi

I was just wondering if given a start_number and end_number would it be possible to generate all the numbers in between them with just a single query ?

Thanks
Kaushik

izaltsman
A custom title

1139 Posts

Posted - 2002-01-16 : 09:10:46
Yeah, it's possible. This article shows how to generate a sequence of dates, but this can easily be changed to generate a sequence of integers in the same fashion.

http://sqlteam.com/item.asp?ItemID=3332


Go to Top of Page

spock
Starting Member

35 Posts

Posted - 2002-01-16 : 09:39:39
izaltsman,

i tried doing as was done in the article but there the problem was the derived tables a0,a1,a2...has to generated upto the upper limit we need. is there any other way where i can do this for quite huge numbers say like 213124552 (just an example) without creating so many number of derived tables ?

Thanks

Go to Top of Page

Arnold Fribble
Yak-finder General

1961 Posts

Posted - 2002-01-16 : 14:50:23
You could use a larger radix, but it's a law of diminishing returns: base 32 you'd still need 6 cross-joined tables (32^5 = 33554432).
But what are you going to do with 200 million integers when you've got them?


Edited by - Arnold Fribble on 01/16/2002 14:56:19
Go to Top of Page
   

- Advertisement -