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)
 A foreign column references to the same table?

Author  Topic 

johnsql
Posting Yak Master

161 Posts

Posted - 2007-01-19 : 11:25:34
Hi,
I have a question about the MEANING of a table column 'PriorLeaseID' which is a FOREIGN key of table 'lease' and then the column references to the same table itself 'lease':


ALTER TABLE [dbo].[Lease] WITH NOCHECK ADD FOREIGN KEY([PriorLeaseID])
REFERENCES [dbo].[Lease] ([leaID])


Thanks in advance

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2007-01-19 : 11:42:27
basically when you add a lease....which is derived/related (according to some business rules) to another lease (already in the system), then your sql definition will check that the instruction to insert/create a new lease verifies that the 'old lease value' supplied actually exist in the system.

your code however does need to be made to work, when there is no priorlease number available/supplied...is when a fresh customer comes inthe door and asks for a lease....
Go to Top of Page
   

- Advertisement -