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
 Transact-SQL (2000)
 Generate Serial numbers for rows

Author  Topic 

iftikharab
Starting Member

1 Post

Posted - 2006-01-07 : 07:57:00
Hi All Experts

i am using vb.6 and sql server 2000, fetching data from server through ado recordset, and assigning it to datagrid control to fill it,
is there any way in sql server to generate serial numbers in rows returned e.g. employee data ( name and salary)
1 Donald 2500
2 Peter 3500
3 Rumz 5000

first field should be generated autometically, rest of the fields are selected from the table.
need this result in a scenerio where sorting is not predefind

Any help would be appreicated

Many thanks in advance

nr
SQLTeam MVY

12543 Posts

Posted - 2006-01-07 : 09:34:08
Have a look at the identity property.
The easiest way is to retrieve the recordset via a stored procedure (you should be doing this anyway) and accumulating the data in a temp table or table variable with an identity column then selecting from this for the result.
You could also calculate the value in the query - but once you are using stored procs for all access you have a lot of flexibility to do whatever you wish.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -