Danish Habib

Danish Habib

  • NA
  • 694
  • 247.2k

SQL Server Reference Deletion of the Record Need Help

Nov 11 2014 1:07 AM
Dear I have Three Tables Districts,Tehsils,Ucs
District(DistrictId(Pk),DistrictName) 
Tehsils(TehsilId(PK),TehsilName,DistrictID(FK))
UC(UCID(PK),UCNAME,TEhsilID(FK),DistrictID(FK))
Now I have relational Database the UC table has the  reference key of DistrictID and tehsil id,same as the tehsils table has the districtId as forign key when i am deleting the tehsil it does not give error of reference key in some other table but when i delete the uc it gives an error that this is reference to some other table as  well ,so delete the primary record first (in my case if i insert a one uc wrong which is associated with some tehsil if i delete teh tehsil first the many other ucs are also associated with this tehsil so i do not want to delete the tehsil because many other ucs are also related with that.
please help  

Answers (1)

0
Vikram Agrawal

Vikram Agrawal

  • 0
  • 411
  • 8.7k
Nov 11 2014 1:44 AM
Hi Dinesh,
first you have to check that UCID column should not associated with any other column
if it is referencing any other column then you will not able to delete UC records
to do this you have to delete first the child records of UCID
Thank You,