Skipping FOREIGN KEY constraint ‘%.*ls’ definition for temporary table. FOREIGN KEY constraints are not enforced on local or global temporary tables.
This informal message appears when you try to create a FOREIGN KEY constraint for a temporary table.
The T-SQL statement can be executed, but the part mentioned in the message will be left out.
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.
All versions of SQL Server.
IF OBJECT_ID(‘tempdb..#t’) > 0
DROP TABLE #t
CREATE TABLE #t
CONSTRAINT FK_t_t1_c1 FOREIGN KEY REFERENCES #t(c1)
In the above example we try to create a FOREIGN KEY constraint for a temporary table. This raises the error.