Hello,
I have 2 tables with a field called userid which is uniqueidentifier and they are both primary keys.
When I add a record to table1 and the userid field is filled, what is the best way to update table 2 with the same record.
Is there an sql function that will update automatically or do I have to write code in vb.net to select the record form table1 and insert into table2.
Thanks
Peter
If you wanted to do it relationship, one of the keys would have to be a foreign key and the other the primary key, probably using a 1 to 1 relationship.
If you want to use two primary keys, you would either need to do it by T-SQL or on the .NET Server end, ex. with VB.NET.
|||What you are looking for is called a DRI(declarative referential integrity) constraint. You create it with the enable relationship dialog box at the top of Management Studio and look for option Cascade on Update. The two links below one explains DRI and the second is a walkthrough to enable it. Hope this helps.
http://msdn2.microsoft.com/en-us/library/ms177288.aspx
http://msdn2.microsoft.com/en-us/library/ms186973.aspx
|||
Thanks guys, working through links now.
Peter
sql
No comments:
Post a Comment