Sql Select statement with auto generated row id

I would like to create a select query statement with autonumber.. like..
select Id,Name frommyTable

will give me everything from table.
The result I’d like to get is..
1         data1
2         data2
3         data3
So i have used the below query
SELECT ROW_NUMBER() OVER (ORDER BY Name) , * FROM myTable

Leave a Reply

Your email address will not be published. Required fields are marked *