Skip to main content

Posts

Showing posts from December, 2012

Query Find the location of a row in a table SQL Server which doesn't have Identity Column

If we don't have any identity column and yet, we wish to see on what position does record lies, here is simple Query I did. We are using  ROW_NUMBER ( ) Without using ORDER BY clause. That means, We are suppressing the effect of ORDER BY Clause used in ROW_NUMBER ( ) CREATE TABLE C ( NAME VARCHAR ( 100 )) INSERT INTO C SELECT ( 'ABC' ) UNION ALL SELECT ( 'bharath' ) UNION ALL SELECT ( 'job' ) UNION ALL SELECT ( 'raghavendra' ) UNION ALL SELECT ( 'anita' ) UNION ALL SELECT ( 'prakash' ) UNION ALL SELECT ( 'dhinakaran' ) SELECT * FROM C  We know name ' Raghavendra ' lies at 4th Position and if we want to get this position number, then, we think of ROW_NUMBER ( ) concept but we know ROW_NUMBER ( ) will order the sequence the Records are stored and then It displays it. So in order to avoid this ordering of the records, I will use some dummy values...