Is there any Property In MS SQL Server Like Rownum in Oracle

A

Ashutosh

Hi All....

I have to write one query where i have to display the ID as 1,2 3, 4 in
oracle we used to ROWNUM to display ....in MS SQL server is there any
property to show???

i have to display like

ID ProgramCount
1 4
2 6
3 5
4 1
5 2

Ashutosh
 
S

Shankar Reddy

I don't think there is a direct way but you can get the same results with the following Select statement.

use pubs
GO
Select IDENTITY(int, 1,1) id, * INTO #Temp from authors
Select * from #Temp


try this.

Thanks,
Shankar Reddy
 
Joined
Mar 1, 2009
Messages
1
Reaction score
0
Row_Number() should do the trick...

Code:
Select
  SalesOrderID, CustomerID, [COLOR="Red"][B]Row_Number() Over (Order By SalesOrderID) as RunningCount[/B][/COLOR]
From
  Sales.SalesOrderHeader
Where
  SalesOrderID > 10000
Order By
  SalesOrderID
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,146
Messages
2,570,832
Members
47,374
Latest member
anuragag27

Latest Threads

Top