Skipping FOREIGN KEY constraint '%.*ls' definition for temporary table. FOREIGN KEY constraints are not enforced on local or global temporary tables.

Error Message:
Skipping FOREIGN KEY constraint ‘%.*ls’ definition for temporary table. FOREIGN KEY constraints are not enforced on local or global temporary tables.

Severity level:

Description:
This informal message appears when you try to create a FOREIGN KEY constraint for a temporary table.

Consequences:
The T-SQL statement can be executed, but the part mentioned in the message will be left out.

Resolution:
Error of this severity level are errors, that do not cause the statement to stop. But not all commands in your statement have been executed.

Versions:
All versions of SQL Server.

Example(s):
USE tempdb;
GO
IF OBJECT_ID(‘tempdb..#t’) > 0
 DROP TABLE #t
GO
CREATE TABLE #t
(
 c1 INT
 CONSTRAINT FK_t_t1_c1 FOREIGN KEY REFERENCES #t(c1)
)
GO

Remarks:
In the above example we try to create a FOREIGN KEY constraint for a temporary table. This raises the error.

]]>

Leave a comment

Your email address will not be published.