1

I'm using SQL-Server 2005.

I have table with many columns, rows i select have where clause which makes impossible to use identity as indexer. I want select all these row + indexer row (acting like identity).

example

2 jack

4 thomas

8 james

to

1 2 jack

2 4 thomas

3 8 james

thanks

1 Answer 1

2

Use rank function or row_number (http://www.databasejournal.com/features/mssql/article.php/3661461/New-Ranking-Functions-within-SQL-Server-2005.htm)

select rank() OVER (ORDER BY list of your columns) as Id, 
your_column_1, your_column_2 ...
from your table
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.