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.
Author |
Topic |
Ronesh
Starting Member
33 Posts |
Posted - 2009-07-14 : 00:45:53
|
I had a problem while creating table.I used the below stated script to create it.CREATE TABLE Employee( EmpId SMALLINT IDENTITY(1,1) PRIMARY KEY , EFname VARCHAR(50) NOT NULL, DeptId CHAR(3) REFERENCES Department(DeptId) )GOCREATE TABLE Department( DeptId CHAR(3) PRIMARY KEY, DeptName VARCHAR(20) NOT NULL, DeptHead SMALLINT REFERENCES Employee(EmpId))GOPlease let me know any one how to create these tables along with the referential integrity.I can do this by altering reference constraint later.i was wondering if i could create it while creating table only.thanks in advance. |
|
TSQLMan
Posting Yak Master
160 Posts |
Posted - 2009-07-14 : 14:58:02
|
To the Best of my knowledge an object in sysobjects must exist before you can create a reference to it, or obviously it's syscolumns, or indexes. What exactly are you trying to achieve? If you provide more info maybe we can help with the underlying reason for needing to do this. |
 |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-07-14 : 15:08:58
|
Can I ask what is the sense of this?Will it be same problem when inserting data? No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|