Skip to main content
3 of 3
Incorporated comment
Paul White
  • 90.3k
  • 30
  • 424
  • 663

In modern versions of SQL Server (2014+) you can create the indexes when you create the table, e.g.:

create table #t(id int primary key, a int, index ix_a nonclustered(a))

Also you can create the temp table before the snapshot transaction starts.

Almost all DDL is prohibited within a SNAPSHOT transaction. ALTER TABLE and TRUNCATE TABLE are obviously not allowable. CREATE TABLE is whitelisted. CREATE INDEX could be whitelisted, but simply isn't.