Thursday, September 16, 2010

Where is ROWID in Sqlserver 2005 like oracle?

The nearest equivilant is the Row_Number() function, but it doesn't work


exactly like the orable version.
Here's an example...

Select firstname,Row_Number() over( order by firstname ) as RowId from mytable Order By Firstname

This will produce the same results. Why is it different? The over part of the command. This specifies the order that the numbers are to be generated. But it's not necessarily the order of the resultset. The order by at the end of the statment does that.

No comments:

Post a Comment