Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 creating table that has a foreing ley

Author  Topic 

johnstern
Yak Posting Veteran

67 Posts

Posted - 2007-06-06 : 16:42:05


I have something like this
CREATE TABLE dbo.Discussion_Image(
ImageID Int PRIMARY KEY,
ImagePath Varchar (300),
GroupID Int REFERENCES Discussion_Image_Group(GroupID),
SortOrder Int,
)

but it does not let me create it until I create the Discussion_Image_Group

sometimes I need it to created regardless because I am not ready to create the other table, any way to disable this check by sql sever ? thank you

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-06-06 : 17:22:35
Obviously you cannot force it to establish it a relationship with a column in a table that does not exist. You can create the table first without the constraint and add the constraint later when the other table is created. Use ALTER TABLE ADD CONSTRAINT syntax to add the FK later.

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page
   

- Advertisement -