ORDINA BLOGT

XML in SQL Server - Indexes

You MUST add indexes to an XML column in SQL Server. If you don't do that, queries will soon become very slow.

  • 18 juli 2012

Just run these statements:

CREATE PRIMARY XML INDEX primaryidx ON [table](XmlColumnname)
GO

CREATE XML INDEX pathidx ON [table](XmlColumnname)
USING XML INDEX primaryidx FOR PATH
GO

CREATE XML INDEX valueidx ON [table](XmlColumnname)
USING XML INDEX primaryidx FOR VALUE
GO

CREATE XML INDEX propidx ON [table](XmlColumnname)
USING XML INDEX primaryidx FOR PROPERTY
GO