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
 General SQL Server Forums
 New to SQL Server Programming
 How to set Foregin Key

Author  Topic 

Easwar
Yak Posting Veteran

59 Posts

Posted - 2007-03-13 : 02:30:21


I've two table.

Table
-------
stu(stuid primary key,name)=======> First table

con(one primary key,two,three,stuuid)=====> Second Table

I need second table(con) Foreign key(stuuid)....

I want stuuid this field Foreign key......

Once insert the value into first table(stu)

Automatically update stuuid this field value..

How to i'll get.* simply stuid,stuuid this two field value are equal *

Any Alter query...........

Plz help me.........



sqllover
Constraint Violating Yak Guru

338 Posts

Posted - 2007-03-13 : 02:45:29
hi easwar go to enterprice manager and right click your second table and choosr design table.in that right clik on the stuid and choose relationships and set foreign key
this would help you
Go to Top of Page

Easwar
Yak Posting Veteran

59 Posts

Posted - 2007-03-13 : 02:53:06
It Can't possible because i used sql server 2005..........
Go to Top of Page

sqllover
Constraint Violating Yak Guru

338 Posts

Posted - 2007-03-13 : 03:02:43
hey otherwise use this query:

for example:
ALTER TABLE Books
ADD CONSTRAINT fk_author
FOREIGN KEY (AuthorID)
REFERENCES Authors (AuthorID)

this would help you
Go to Top of Page

Easwar
Yak Posting Veteran

59 Posts

Posted - 2007-03-13 : 03:13:09
Hey

Thank You very much..........

That query worked.........
Go to Top of Page
   

- Advertisement -