HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlMinor

Can you create a primary xml index in the CREATE TABLE statement (SQL Server)?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
cantheprimarycreateyoustatementsqlxmlserverindex

Problem

I'm creating a temporary table and would like to create a primary and secondary XML index on a contained xml column within the CREATE TABLE statement since that is the only way I can create an index without throwing an error under snapshot isolation.

I know the syntax for creating standard (non-XML) clustered and nonclustered indexes inline, and it works fine, but I don't seem to be able to find a syntax that works for XML indexes either in documentation or via experimentation.

Does anyone know whether this is possible?

Solution

I just tried using the XML index creation commands in-lined with a table creation, and it didn't work.

I stumbled upon this article that makes it look like trying to create non-relational indexes (XML, columnstore, or spatial) doesn't work with in-lining the index creation statement in the table definition.

Context

StackExchange Database Administrators Q#269223, answer score: 3

Revisions (0)

No revisions yet.