January 12, 2015 at 9:56 pm
Is there any difference between Row index and row number in sql?
January 13, 2015 at 1:34 am
There's no such thing as a 'row index' in SQL. Did you mean an identity column? Something else?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
January 13, 2015 at 4:20 am
I've seen the output of ROW_NUMBER() referred to as row index (incorrectly), but other than that, I'm with Gail. I don't understand the question.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
January 13, 2015 at 5:15 am
I thought row number and row index are different concepts .. That's why I ask this question .. Thank you
January 13, 2015 at 5:24 am
Well, they are. In the sense that Row Number exists and Row Index doesn't.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
January 13, 2015 at 5:30 am
okay.. Thank you ..:-)
January 13, 2015 at 6:24 am
Unless we're looking at some of kind of terminology mix up. Maybe you meant RID, or Row Identifier, which is a marker placed on rows in a heap table. Just guessing to try to help.
What did you think each of these things did?
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
January 13, 2015 at 8:52 pm
I got some idea about row number and row Id as :
row id is the unique index number of every row of table maintaining by database automatically and
row number is the sequential number of rows in the resultset object.
But thought rowIndex is another concept ..
My question was about that concept . If its not exists , its cleared ...:-)
January 14, 2015 at 1:14 am
hazeenahazu (1/13/2015)
I got some idea about row number and row Id as :row id is the unique index number of every row of table maintaining by database automatically and
row number is the sequential number of rows in the resultset object.
Neither of those is true.
SQL doesn't keep a unique number for each row of each table. You, as the developer, can set a column to be an identity which means it's auto-incremented for new rows. It's still not unique.
Rows in a resultset don't get a sequential number automatically. You can use something like Row_Number as a column in the resultset with a sequential number based on the grouping and ordering specified in the function.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
January 14, 2015 at 1:49 am
"You, as the developer, can set a column to be an identity which means it's auto-incremented for new rows. It's still not unique. "
- Did you mean the primary key as an identity column ?
like,
CREATE TABLE dbo.Tmp_Names
(
Id int NOT NULL PRIMARY KEY IDENTITY(1, 1),
Name varchar(50) NULL
)
Then why its not unique?
January 14, 2015 at 2:12 am
That one is unique, because it's a PRIMARY KEY. It's the PRIMARY KEY which forces the column to be unique, not the identity. Identity just provides incrementing values.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
January 14, 2015 at 2:40 am
I am a little confused about those things ..:-(
Then how does we create this identity column ?
January 14, 2015 at 2:47 am
What?
Your example above created a column with identity, so why are you asking how to create a column with identity?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 13 posts - 1 through 13 (of 13 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy