Cannot use index "%.*ls" on table "%.*ls" in a hint. XML indexes are not allowed in hints.

Error Message:
Msg 309, Level 16, State 1, Line 1
Cannot use index “%.*ls” on table “%.*ls” in a hint. XML indexes are not allowed in hints.

Severity level:
16.

Description:
This error message appears when you try to force the usage of an XML index in a hint.

Consequences:
The T-SQL statement can be parsed, but causes the error at runtime.

Resolution:
Errors of the Severity Level 16 are generated by the user and can be fixed by the SQL Server user. The statement cannot be executed this way. You cannot force SQL Server to use an XML index in a hint.

Versions:
This error message was introduced with SQL Server 2005.

Example(s):
USE tempdb;
GO
CREATE TABLE #t (c1 int PRIMARY KEY, xml1 xml);

CREATE PRIMARY XML INDEX IX_XML_t ON #t(xml1);

SELECT
    *
FROM
    #t WITH (INDEX = IX_XML_t);

DROP TABLE #t;

Remarks:
In the above example we try to force SQL Server to use the index ‘IX_XML_t’. Because this index is an XML index, the error is raised.

]]>

Leave a comment

Your email address will not be published.