You cannot make Foreign Key relationship on the Temporary Tables

If you are working with the temporary tables than keep in mind you cannot make foreign key relationships to other tables. Check out the T-SQL code below.

CREATE TABLE #Person 
(
PersonID 
int identity(1,1) PRIMARY KEY,
FirstName nvarchar(20), 
LastName nvarchar(20) 
)

CREATE TABLE 
#Phone
(
PhoneID 
int identity(1,1) PRIMARY KEY, 
PhoneNumber nvarchar(20), 
PersonID 
int FOREIGN KEY REFERENCES Person(PersonID) -- Naa cannot do this Dude!!
ON DELETE NO ACTION  
)

 

 


powered by IMHO

Print | posted @ Monday, September 19, 2005 10:58 PM

Twitter