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)
 add a row number field to the resultset of a SQL Statement

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-04-23 : 16:59:58
Trevor writes "Will it be possible for me to add a row number field dynamically to the output of a SQL Statement. The underlying table does not have identity column. The query goes something like this "Select field1, field2, field3 From Table1". Along with this I need the row number to be one of the columns. so that the output will look like.

rowno    fiel1    field2     field3
-----------------------------------
1 Value11 Value12 Value13
2 Value21 Value22 Value23
3 Value31 Value32 Value33
4 Value41 Value42 Value43
.....



I just need to know about auto generating this row number or is there a @@variable that I can use."
   

- Advertisement -