Hi Friends,

There may be various cases where you can use the term records and rows interchangeably in SQL Server database world. Can we use the term records and Rows interchangeably in the case of Heap?  We will try to find out the answer of this question in this post.

We know that Heap in SQL Server is a table structure without clustered index. Let me create one Heap with some data. After that I’ll try to find out the Row count from heap and Record count on the same heap by using sys.dm_db_index_physical_stats dmv.

Records versus Rows in Heap1

From the above output you can see the number of records and numbers of rows both are same. Now let’s try to update qualities column with some large data by using replicate function. Then again we will compare number of records and number of rows.

Records versus Rows in Heap2

Now in the above output record count and row count both are different. I hope you got the answer for question which is asked in the first block of this post.  Now the next question will come in your mind: what is the reason behind this. Reason is also there in both the above outputs. Go to above outputs back and check the value in column forwarded_record_count. First output showing value 0 while second output is showing value 1.

As per BOL, forwarded record count is the Number of records in a heap that have forward pointers to another data location. (This state occurs during an update, when there is not enough room to store the new row in the original location.)

HAPPY LEARNING!

Regards:
Prince Kumar Rastogi

Like us on FaceBook | Join the fastest growing SQL Server group on FaceBook

Follow Prince Rastogi on Twitter | Follow Prince Rastogi on FaceBook