Monday, September 16, 2013

Indexing SQL rows

Hi, this is another short blog post from before I hit the sack, so forgive it's bluntness.

Ever needed to return a set of data from SQL with index? One way of doing this is by the use of incremental counters, but one thing I've used was "Row_Number . Here's how to use it.

Select Row_Number () over (order by ID) AS Row,  Column1,  Column2,  from Employee
This query will give you an extra row with the name "Row" which will now serve as your index.

Hope this helps. Happy Coding!!

No comments:

Post a Comment