This article is half-done without your Comment! *** Please share your thoughts via Comment ***
In the previous two posts, I shared basic about Forwarding Records of Heap Table and shared a script to find the count of Forwarded Records in SQL Server.
In this post, I am sharing a practical demonstration on Forwarding Records like generate Forwarding Records and then Remove those Forwarding Records.
Please check the below full demonstration:
Create a sample HEAP table:
1 2 3 4 5 6 |
CREATE TABLE tbl_Heap ( Col1 INT IDENTITY(1,1) ,Col2 VARCHAR(1000) ) GO |
Insert sample records with VARCHAR(5) size:
1 2 3 |
INSERT INTO tbl_Heap (Col2) VALUES ('dbrnd') GO 1000 |
Now, Update the data from VARCHAR(5) to VARCHAR(31):
1 2 3 |
UPDATE tbl_Heap SET Col2 = 'Database Research & Development' GO |
Check the count of Forwarding Records:
For removing Forwarding Records, we should REBUILD the table:
1 2 |
ALTER TABLE tbl_Heap REBUILD GO |
Now, Check the new count of Forwarding Records:
The count is 0 now.
Leave a Reply