Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How get rowId in a select statement?

 
Dan Bizman
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way to do something equivalent to the following in a SQL select statement (either ANSI SQL or Transact-SQL is fine):

SELECT ROWNUMBER(), Name FROM SomeTable

Which would then print out:

1 Tom
2 Jack

(And yes I know that an identity column would result in the same output, but there's no identity on the table I have to work with and I can't change it, so that's not an option. Also I DO need it on the DB side, NOT after it's returned.)

I know "ROWNUMBER" doesn't exist, but is there any way to get that info inside the select as it's building?
 
Scott Johnson
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://support.microsoft.com/kb/186133

HTH
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic