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.
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.
The T-SQL statement can be parsed, but causes the error at runtime.
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.
This error message was introduced with SQL Server 2005.
IF OBJECT_ID(‘tempdb..#t’) > 0
DROP TABLE #t
CREATE TABLE #t
id INT NOT NULL,
t1 TIMESTAMP NOT NULL,
ALTER TABLE #t
ADD CONSTRAINT PK_t PRIMARY KEY(id, t1)
CREATE PRIMARY XML INDEX IX_XML_t_c1
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.