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 2005 Forums
 Transact-SQL (2005)
 Silly but i cant..... help me

Author  Topic 

sudheer.v538@gmail.com
Starting Member

10 Posts

Posted - 2007-07-31 : 09:01:55
Hi forum members...
I need a query to get the numbers inbetween 1 and 50.
Here i know first record id = 1 and max(id) = 50. I need the output like...
1
2
3
4
.
.
.
50
Please help me...

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-07-31 : 09:03:53
Simulate this logic
http://sqljunkies.com/WebLog/aferrari/archive/2007/07/02/41908.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-07-31 : 09:20:46
If lower limit is greater than or equal to zero, and upper limit is less than or equal to 255 in sql server 2000 (2047 in sql server 2005), you can use

SELECT Number FROM master..spt_values WHERE Type = 'p' AND Number BETWEEN 1 AND 50



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2007-07-31 : 09:29:20
You could use the function on this link.

Number Table Function
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=47685

select number from F_TABLE_NUMBER_RANGE(1,50)






CODO ERGO SUM
Go to Top of Page
   

- Advertisement -