Know the answer? Post it. Somebody with the same question will find it here.
Ravi Kiran ChanduriRank #1,159 · 1.6K reputationPosted Jul 20, 2018, 5:20 AM EDT
+2
Hello Sanwar Ranwa,
Row_Number in SQL server is used to set the numbers for selected results.
For example :
Let's assume we have a table called EMP with Name and Age as columns
we need the result with sequence numbers of the rows to do some operation with the result.
In this situation, we use ROW_NUMVER() to assign the sequence numbers to the result.
createtable #EMP (Namevarchar(100), Age INT)
Insertinto #EMP VAlues('XXXXX',24)
Insertinto #EMP VAlues('YYYYY',24)
Insertinto #EMP VAlues('ZZZZZ',24)
Insertinto #EMP VAlues('WWWWW',24)
SELECT
ROW_NUMBER() OVER(ORDERBYnameASC) AS Row#,
name, Age
FROM #EMP
Here, we get the result as below
ROWID , I searched for ROWID in SQL. I didn't find anything with this keyword in SQL.
Guys, correct me if I am wrong. I saw that ROWID is the key work in Oracle where we get the actual/ physical location of a particular row in the DB(to technically say, the address of the row).
Row_Number is one of these functions available in SQL Server that allows us to assign rankings or numbering to the rows of the result set data. Different values are assigned to different rows, based on the type of ranking function used. They are basically of the following types: Row_Number.
ROWID is the physical location of a row. Consequently it is the fastest way of locating a row, faster even than a primary key lookup. So it can be useful in certain types of transaction where we select some rows, store their ROWIDs and then later on use the ROWIDs in where clauses for DML against those same rows
Ravi Kiran ChanduriRank #1,159 · 1.6K reputationPosted Jul 20, 2018, 5:20 AM EDT
Kapil Singh KumawatRank #735 · 3.2K reputationPosted Jul 20, 2018, 10:29 PM EDT
Shashangka ShekharRank #456 · 5.5K reputationPosted Jul 18, 2018, 5:05 PM EDT
Sanwar RanwaRank #23 · 44.7K reputationPosted Jul 18, 2018, 8:22 PM EDT
Packiaraj SanthiyaguRank #659 · 3.6K reputationPosted Jul 27, 2018, 9:28 PM EDT
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts