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)
 Selecting Row numbers from a query

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-07-02 : 16:23:16
Jerald writes "Hi SQL team... My Q to you is as described below...
I have a table with some records in it (say about 100).. I have to write a Select query to fetch some no. of records from the table (say 10) with no field such as serial no.. etc.. in it..

I have to get the serial numbers as 1,2,3,4.... so on (which will be generated dynamically in the query itself) for the 10 records that I have fetched with the data as well.. I have tried to get help from Books Online but did not find anything in it as yet.. or maybe in that case I did not search it properly..

First of all can I do such a thing without using any stored procedure, just simple select query.. I will be glad if I can get a soln. to this problem..

for an Example the data in the table would like this

col1       col2
----- ----
JER JERRY FERNANDES
CAL CALISTER CARVALO
SAN SANDRA DEMELLO

and so on...

The result set should be like this

Sr No. col1 col2
----- ----- -------
1 JER JERRY FERNANDES
2 CAL CALISTER CARVALO
3 SAN SANDRA DEMELLO


and so on...


I am using SQL Server 7 on Windows 2000 Server

Thanking You All there..

Regards...


Jerald"
   

- Advertisement -