The target table ‘%.*ls’ of the OUTPUT INTO clause cannot have any enabled check constraints or any enabled rules. Found check constraint or rule ‘%ls’.

Error Message:
Msg 333, Level 16, State 1, Line 7
The target table ‘%.*ls’ of the OUTPUT INTO clause cannot have any enabled check constraints or any enabled rules. Found check constraint or rule ‘%ls’.

Severity level:
16.

Description:
This error message appears when you try to insert rows via the OUTPUT INTO clause into a table for which a CHECK constraint for one of ist columns exists.

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

Resolution:
Errors of the Severity Level 15 are generated by the user and can be fixed by the SQL Server user. The statement cannot be executed this way. You must remove the constraint and/or rule before you can successfully execute such a statement.

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

Example(s):
USE Northwind;
GO
CREATE TABLE #t
(
 OrderID int
 CONSTRAINT chk_t_orderID CHECK (OrderID > 0)
)

UPDATE TOP (10) Orders
   SET OrderDate = DATEADD(DAY, 1, OrderDate)
OUTPUT INSERTED.OrderID
  INTO #t;

DROP TABLE #t;

Remarks:
This error can easily be circumvented by a change of the programm logic and the addition of a staging table, for example.




Related Articles :

  • No Related Articles Found

No comments yet... Be the first to leave a reply!

Software Reviews | Book Reviews | FAQs | Tips | Articles | Performance Tuning | Audit | BI | Clustering | Developer | Reporting | DBA | ASP.NET Ado | Views tips | | Developer FAQs | Replication Tips | OS Tips | Misc Tips | Index Tuning Tips | Hints Tips | High Availability Tips | Hardware Tips | ETL Tips | Components Tips | Configuration Tips | App Dev Tips | OLAP Tips | Admin Tips | Software Reviews | Error | Clustering FAQs | Performance Tuning FAQs | DBA FAQs |