Cannot create primary xml index '%.*ls' on '%.*ls' because PRIMARY KEY constraint contains column(s) of type timestamp.

Error Message:
Msg 2735, Level 16, State 201, Line 1
Cannot create primary xml index ‘%.*ls’ on ‘%.*ls’ because PRIMARY KEY constraint contains column(s) of type timestamp.

Severity level:
16.

Description:
This error message appears when you try to create a XML index on a table for which the PRIMARY KEY constraint includes a column of the TIMESTAMP data type.

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

Resolution:
Error 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. The XML index cannot be created on the table as long as the PRIMARY KEY constraint contains the TIMESTAMP column.

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

Example(s):
USE tempdb;
GO
IF OBJECT_ID(‘tempdb..#t’) > 0
 DROP TABLE #t
GO
CREATE TABLE #t
(
 id INT NOT NULL,
 t1 TIMESTAMP NOT NULL,
 c1 XML
)
GO
ALTER TABLE #t
  ADD CONSTRAINT PK_t PRIMARY KEY(id, t1)
GO
CREATE PRIMARY XML INDEX IX_XML_t_c1
    ON #t(c1);
GO

Remarks:
In the above example we try to create a XML index for the tablt #t. Because the PRIMARY KEY constraint of #t contains a column of the type TIMESTAMP, the error is raised.

]]>

Leave a comment

Your email address will not be published.