what is the use of Row_Number() OVER in Sql Server?


Row_Number() OVER is used to generate the row numbers automatically. The following query is used to generate the row number automatically in sql server.

one of the features that to discuss in this article is the Row_Number() function. Row_Number() OVER is used to generate the row numbers automatically. The following query is used to generate the row number automatically in sql server.





Select Row_Number() OVER(Order By column1) As RowNumber,column1,column2 From TableName

Ex:
Select Row_Number() OVER(Order By EmpId) As RowNumber,EmpId,EmpName,Dob,Address,City,Phone From Employee



Comments

Guest Author: Nagesh19 Feb 2012

I experienced the same. Upgrade logs show the SQL 2005 SP3 hot fix KB970892 as successful, but after any reboot it is indicated as a need important upgrade. After several attempts (each successful) I gave up.



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: