Msg 3734, Level 16, State 1, Line 1
Could not drop the primary key constraint ‘%.*ls’ because the table has an XML index.
This error message appears when you try to remove a PRIMARY KEY constraint from a table which has an XML index.
The T-SQL statement can be parsed, but causes the error at runtime.
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. Before you can remove the PRIMARY KEY constraint, you must drop the XML index first.
This error message was introduced with SQL Server 2005.
IF OBJECT_ID(‘tempdb..#t’) > 0
DROP TABLE #t
CREATE TABLE #t
CONSTRAINT PK_t PRIMARY KEY,
c2 AS id * 4
CREATE PRIMARY XML INDEX IX_XML_t_c1
ALTER TABLE #t
DROP CONSTRAINT PK_t;
In the above example we try to remove the PRIMARY KEY constraint from the table #t. Because #t has an XML index, the error is raised.