Enforcing Referential Integrity on Temp table (Local and Global) not supported/possible!
The reason may be one/all of the followings..
1. #Table (Local Temp Table) is the scope/session level. Out of the session/scope It can not be accessed.
2. ##Table (Global Temp Table) is the session/connection level. It can not be accessed once the source connection/session where it originally created is Closed.
- So, What will happen when referring/forcing the Constraint on it ?
(or)
- Once restarted the service, the Tempdb database will be recreated, So all the user defined objects also will not be there!
One of the following error will be thrown:
Foreign key references to temporary tables are not supported
(or)
Skipping FOREIGN KEY constraint '#Table' definition for temporary table. FOREIGN KEY constraints are not enforced on local or global temporary tables.
Cheers
www.SQLServerbuddy.blogspot.com
iLink Multitech Solutions
Jasminej, if this helps please login to Mark As Answer. | Alert Moderator