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 2000 Forums
 SQL Server Development (2000)
 SQL2000 Relationship with PK and FK

Author  Topic 

peterwilson
Starting Member

15 Posts

Posted - 2008-07-04 : 01:24:52
Hi friends,

i want the help on SQl Server 2000,

how i can connect 2 database
with the Foregion key and Primary key relationship

so data can be inserted on one table may added to another table also.

i m also creating a Relationship on SQL2000 , but data cant be inserted while one table affected.

i have also done same thing in MSAccess , that time i can get the
value from other table means [ whn i clik on + sign that time it show
child value , means other table value , ]

but here in SQl2000 i DOnt get it , so plz try to help me with
the exact procedure .


Thankx in advance

Rajani@30
Starting Member

6 Posts

Posted - 2008-07-04 : 04:37:15
you can create a trigger for insert on the table having the primary key. and in trigger u can get the values inserted from the inserted table(which is created internal by the SQL)to insert into the second table.
Go to Top of Page

peterwilson
Starting Member

15 Posts

Posted - 2008-07-04 : 04:51:56
thnx rajani fr reply...

actually this is also one way ..

but can i do it manually like i was explain in my Question [ MSACCESS]

fine can u tell me how i can do this using trigger ..

can u send me some code or Example of same

thank'x
Go to Top of Page

Rajani@30
Starting Member

6 Posts

Posted - 2008-07-04 : 05:22:28
This link below will describe you how to sue the trigger on tables:
http://www.dba-sql-server.com/sql_server_tips/t_super_sql_423_cascade.htm

Rajani
Go to Top of Page

Rajani@30
Starting Member

6 Posts

Posted - 2008-07-04 : 05:23:15
correction in the prev post: its not sue, its use..
sorry about tht

Rajani
Go to Top of Page

Rajani@30
Starting Member

6 Posts

Posted - 2008-07-04 : 05:59:15
If u want to do it manually, you will have to create an SP which inserts the record in the first table and returns the @@identity (primary key).
and using this returned value, call one more SP to insert the record in the second table.
Go to Top of Page

peterwilson
Starting Member

15 Posts

Posted - 2008-07-05 : 04:42:36
nice way ..

thnx rajani 4 de great help?

ya with de help of SP its possible..

thankx ones again.
Go to Top of Page
   

- Advertisement -