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
 sql referential integrity

Author  Topic 

rjhe22
Constraint Violating Yak Guru

283 Posts

Posted - 2008-11-20 : 04:43:17
and we would start by finding the receiptID from the DA linking on EntryID where the DA is the one we are interested in

would this code be right for the above statement
select da. DebitAuthorityID,

r.ReceiptID,
cl.EntryID
From DebitAuthority da
inner
join dbo.DebitAuthorityJournal daj
on daj.DebitAuthorityID = da.DebitAuthorityID
inner
join dbo.Clientledger cl
on cl.EntryID = daj.EntryID
inner
join dbo.Receipt r
on r.EntryID = daj.EntryID

where da. DebitAuthorityID = '5386'

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-20 : 05:50:21
didnt get what you're asking for. can you explain?
Go to Top of Page

rjhe22
Constraint Violating Yak Guru

283 Posts

Posted - 2008-11-20 : 05:58:12
i have to delete a receipt from a table but it is reference in a few tables the one s above. need to get the entryid to delete it

i have a database design i could post might explain it better
Go to Top of Page

rjhe22
Constraint Violating Yak Guru

283 Posts

Posted - 2008-11-20 : 06:05:01
how do u post an image here. i might be able to explain it better that way
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-20 : 06:17:05
quote:
Originally posted by rjhe22

i have to delete a receipt from a table but it is reference in a few tables the one s above. need to get the entryid to delete it

i have a database design i could post might explain it better


you need to find & delete dependent records from referred tables before deleting it from master table, if thats what you were asking.
Go to Top of Page

rjhe22
Constraint Violating Yak Guru

283 Posts

Posted - 2008-11-20 : 06:22:03
yes basically
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-20 : 06:29:17
look into foreign key relatinships and start from child table backwards deleting records.
Go to Top of Page

rjhe22
Constraint Violating Yak Guru

283 Posts

Posted - 2008-11-20 : 06:32:17
ok is there any sample u could put up so i could see not sure how to do that
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-20 : 06:33:26
quote:
Originally posted by rjhe22

ok is there any sample u could put up so i could see not sure how to do that


you need nothing more than a series of
DELETE FROM table WHERE...
statements
Go to Top of Page
   

- Advertisement -