SQL Server – Do Primary Keys Change When Indexes Are Rebuilt or Reorganized?

indexprimary-keysql server

I have a database containing tables that each have auto-increment int columns serving as the primary key column.

When I do a rebuild or reorganize operation on my indexes, does either operation potentially change the values of this column?

Does it matter if the indexes are 'clustered'?

I'm using various versions of MS T-SQL from 2008 onward.

Best Answer

No, they will not.

Rebuilding or reorganizing an index should never alter the underlying data itself, only its placement within database pages / extents.

However, as an aside have a read through this post - you might find that you don't need to rebuild these indexes in the first place.