Brian's Blog

items I see across my tribes

Rownum in SQL Server

July 22
by briancarter 22. July 2010 06:54

Prior to SQL Server 2005, there was no inherent function to generate a rownumber within a row. If you are on SQL 2005+, then you will utilize the following function:

-- SQL 2005+
SELECT
    RowNumber = ROW_NUMBER() OVER (ORDER BY a.AttributeID ASC)
    ,a.*
FROM Attribute a

This will return a column with 'RowNumber’ as the first column. 

Categories: Development


 Questions or Feedback, my contact information is located on my About page.


The opinions, thoughts, and comments made in these blog posts are solely my own (unless otherwise stated). They do not reflect the opinions, thoughts or practices of my employer, my universities, my family, or anyone else. Also, I retain the right to change my mind about anything I publish here without having to go back and edit posts that occurred in the past. 

These are my opinions, or just as likely, someone else's opinions that I leveraged for my own.