Core component of SQL Server for storing, processing, and securing data
You’re correct — in SQL Server transactional replication, index operations (CREATE INDEX, DROP INDEX, ALTER INDEX, REBUILD INDEX, etc.) are not replicated to the subscribers.
Transactional replication replicates data changes (DML) and, if configured, some schema changes (DDL). Replication ignores non-clustered index changes because indexes are considered performance/physical design objects, not part of the logical schema needed for replication. The clustered index is implicitly replicated since it defines the table’s storage structure (e.g., if the publisher table has a clustered PK, that’s part of the schema).
For nonclustered indexes, if you want them on the subscriber, you must:
- Create them manually, or
- Script them during the initial snapshot (by including indexed objects in your snapshot pre/post scripts).
This is by design. Microsoft lets you tune subscriber indexes independently for reporting/offloading scenarios, rather than forcing the same indexing strategy as the publisher.
If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.
hth
Marcin